[issue7989] Add pure Python implementation of datetime module to CPython
Alexander Belopolsky
report at bugs.python.org
Thu Jun 17 17:35:12 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
> The only alternative is to manually duplicate tests, these leads to very
> poor test coverage because of the average developer's laziness (json is
> an example).
No, here is another alternative:
==> _example.py <==
def foo():
print(__name__)
==> example.py <==
def foo():
print(__name__)
try:
from _example import *
except ImportError:
pass
==> test_example.py <==
import sys
sys.modules['_example'] = None
import example
example.foo()
del sys.modules['_example']
import _example as example
example.foo()
With the code above,
$ ./python.exe test_example.py
example
_example
If we move import to setUp(), we can run each test case twice: with and without native code. Tests that are specific to one implementation can be run once or skipped conditionally on per test method basis.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7989>
_______________________________________
More information about the Python-bugs-list
mailing list