Comments (8)
I'm sorry for resurfacing this very old issue. Please ignore my stupidity. After extensive debugging, I discovered that an instance of the _freeze_time
class was making its way into the dict I was trying to copy. Resolving that fixed my problem. Nothing to see here. Move along.
from freezegun.
This was also fixed by 0453e5f
from freezegun.
@spulec , I think this is still an issue, or something changed in later releases...
Failing test:
@freezegun.freeze_time('2001-01-01')
def test_picke_mock_time():
import cPickle as pickle
data = {'time': datetime.datetime.utcnow()}
result = pickle.loads(pickle.dumps(data))
compare(result, data)
Runs fine without the freezegun decorator, with the decorator, raises:
PicklingError: Can't pickle <type 'datetime.datetime'>: it's not the same object as datetime.datetime
It would be good to have this test as a regression.
I would send a pull-request, but I can't figure why it is broken. Maybe you can find the problem using this test.
from freezegun.
Ah, you are correct. It looks like I fixed now()
, but not utcnow()
. Fixed with 768a60f and added tests. Going to push a new release in a minute.
from freezegun.
Also, thanks!
from freezegun.
Still happening with cPickle and python-rq.
File "local/lib/python2.7/site-packages/rq/job.py", line 303, in save
obj['data'] = dumps(self.job_tuple)
cPickle.PicklingError: Can't pickle <type 'datetime.datetime'>: it's not the same object as datetime.datetime
from freezegun.
I believe that's the same issue as #30
from freezegun.
Has this regressed in 0.3.x? I'm getting TypeError: can't pickle NotImplementedType objects
when trying to copy.deepcopy
any object with a faked date/time/datetime in it.
from freezegun.
Related Issues (20)
- Timezone America/Sao_Paulo triggers recursion errors in tests. HOT 3
- Maintenance plans HOT 3
- 1.3.0: `freezegun/__init__.py` is missing new version number HOT 1
- [Discussion] about freezing asyncio HOT 7
- ``PermissionError: [Errno 1] Operation not permitted`` appears when upgrading to ``1.3.0`` HOT 7
- Freezegun doesn't mock pointers to date functions HOT 1
- Tag for 1.2.2 is missing HOT 1
- Python 3.12: Deprecation warnings related to datetime.datetime.utcfromtimestamp HOT 2
- Time is not freezed when using `uvloop` event loop
- unsupported operand type(s) for +: 'FakeDatetime' and 'FakeDatetime'
- Datetime and Time packages do not have the same behavior when being frozen HOT 4
- timezone free datetime.datetime.fromtimestamp returns original datetime.datetime HOT 1
- Adding a return value to tick()
- Could have some problem with Django with TIME_ZONE setting
- Test regressions on Python 3.13.0b1 HOT 2
- `FakeDatetime`'s `timestamp()` is not consistent with `datetime().timestamp()` HOT 1
- consider overriding == on FakeDatetimeMeta HOT 2
- Freeze time doesn't work with FastAPI + pydantic V2 HOT 2
- [Bug] `tz_offset` shifts `datetime` which is instantiated with `tz` argument
- Possible to patch user-defined functions?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freezegun.