atd issueshttps://foss.heptapod.net/gracinet/atd/-/issues2020-04-23T20:21:12Zhttps://foss.heptapod.net/gracinet/atd/-/issues/2Proper handling of time zones2020-04-23T20:21:12ZGeorges RacinetProper handling of time zones*Created originally on Bitbucket by Anonymous*
Currently, our ``now()`` and ``set_now()`` simply don't handle time zones at all.
The tricky part would be what to do in case a naive date time is set and some application code uses the ...*Created originally on Bitbucket by Anonymous*
Currently, our ``now()`` and ``set_now()`` simply don't handle time zones at all.
The tricky part would be what to do in case a naive date time is set and some application code uses the time zone optional argument of ``now()`` : issue an error ? take an arbitrary decision ?
https://foss.heptapod.net/gracinet/atd/-/issues/4Missing support for time.strftime()2020-04-23T20:21:14ZGeorges RacinetMissing support for time.strftime()*Created originally on Bitbucket by Anonymous*
The most used way to get the date in openerp is with ```time.strftime("%Y-%m-%d")```
This is currently not supported:
```
>>> import anybox.testing.datetime
>>> import time
>>> from ...*Created originally on Bitbucket by Anonymous*
The most used way to get the date in openerp is with ```time.strftime("%Y-%m-%d")```
This is currently not supported:
```
>>> import anybox.testing.datetime
>>> import time
>>> from datetime import datetime
>>> datetime.set_now(datetime(2222, 1, 1))
>>> datetime.now()
datetime(2222, 1, 1, 0, 0)
>>> time.strftime("%Y-%m-%d")
'2014-05-03'
>>>
```https://foss.heptapod.net/gracinet/atd/-/issues/5Sensitivity to ordering of imports2020-04-23T20:21:15ZGeorges RacinetSensitivity to ordering of imports*Created originally on Bitbucket by Anonymous*
Currently, anybox.testing.datetime must be imported first, in order to replace the standard library's datetime module with its modified version, befiore other modules have imported it.
T...*Created originally on Bitbucket by Anonymous*
Currently, anybox.testing.datetime must be imported first, in order to replace the standard library's datetime module with its modified version, befiore other modules have imported it.
This is in practice hard to enforce in large framework contexts : the testrunner will be imported first no matter what, and in cases such as OpenERP, we have the policy to load the whole database before importing the tests with a runner such as nose (to avoid breaking havoc in the framework's dynamic module injection).
anybox.testing.datetime should provide a way to become insensitive to these orderings problems.https://foss.heptapod.net/gracinet/atd/-/issues/7anybox.testing.datetime breaks pandas2020-04-23T20:21:17ZGeorges Racinetanybox.testing.datetime breaks pandas*Created originally on Bitbucket by Anonymous*
In a new virtualenv, type:
```
#!bash
pip install pandas anybox.testing.datetime
python -c "import anybox.testing.datetime; import pandas"
```
The result currently is:
```
...*Created originally on Bitbucket by Anonymous*
In a new virtualenv, type:
```
#!bash
pip install pandas anybox.testing.datetime
python -c "import anybox.testing.datetime; import pandas"
```
The result currently is:
```
lib/python2.7/site-packages/pandas/_libs/__init__.py:3: RuntimeWarning: datetime.datetime size changed, may indicate binary incompatibility. Expected 64, got 48
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "lib/python2.7/site-packages/pandas/__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "lib/python2.7/site-packages/pandas/_libs/__init__.py", line 3, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
File "pandas/_libs/tslib.pyx", line 895, in init pandas._libs.tslib (pandas/_libs/tslib.c:119406)
File "pandas/_libs/tslib.pyx", line 815, in pandas._libs.tslib.NaTType.__new__ (pandas/_libs/tslib.c:16544)
TypeError: __new__() takes exactly one argument (4 given)
```
Notice that the error doesn't happen if you invert the import order.
Currently this bug breaks running Odoo tests run with `test_odoo` from `anybox.recipe.odoo` if an addon imports `pandas` at the module level.https://foss.heptapod.net/gracinet/atd/-/issues/8Import broken on python32020-04-23T20:21:18ZGeorges RacinetImport broken on python3*Created originally on Bitbucket by Anonymous*
On Python3 (3.5.3), after installing with `pip install anybox.testing.datetime`, I get the following error:
>>> import anybox.testing.datetime
Traceback (most recent call last):
File...*Created originally on Bitbucket by Anonymous*
On Python3 (3.5.3), after installing with `pip install anybox.testing.datetime`, I get the following error:
>>> import anybox.testing.datetime
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user_name/.local/lib/python3.5/site-packages/anybox/testing/datetime/__init__.py", line 2, in <module>
import mock_dt
ImportError: No module named 'mock_dt'
The solution is to change __init__.py to import this way:
from . import mock_dt
from . import mock_time
Also the import of mock_dt on sqllite3.py has to change to:
from .mock_dt import original_datetime (notice the leading dot before mock_dt)