AttributeError: __module__ in doctest
Hello,
I am running into errors & warnings when trying to run Orekit tests with doctest. When collecting tests, it analyzes the classes (all the 1000+ wrapped Java classes it seems) and runs into the following error:
[...]/lib/python3.7/site-packages/pytest_doctestplus/plugin.py:137: in collect
for test in finder.find(module):
[...]/lib/python3.7/site-packages/pytest_doctestplus/plugin.py:425: in find
extraglobs)
[...]/lib/python3.7/doctest.py:932: in find
self._find(tests, obj, name, module, source_lines, globs, {})
[...]/lib/python3.7/doctest.py:993: in _find
self._from_module(module, val)):
[...]/lib/python3.7/doctest.py:960: in _from_module
return module.__name__ == object.__module__
E AttributeError: __module__
In doctest (https://github.com/python/cpython/blob/master/Lib/doctest.py#L959), the inspect.isclass(object)
condition at line 959 returns True
, and therefore doctest tries to access the object's __module__
attribute, which does not seem to exist.
Besides, pytest prints a warning for each Java class being wrapped, also because they have no module attribute:
[...]/lib/python3.7/importlib/_bootstrap.py:219: DeprecationWarning: builtin type ExtendedKalmanFilter has no __module__ attribute
return f(*args, **kwds)
This phenomenon is new because 6 months ago I could run pytest & doctest successfully with Orekit. I could not find which module contains the change that broke stuff since then though.
To reproduce the phenomenon, you can check out https://github.com/GorgiAstro/poliastro/blob/orekit-validation/src/poliastro/tests/tests_twobody/test_propagation.py#L164 I was trying to validate some poliastro features using the Orekit python wrapper. So this code requires poliastro, it is available on conda-forge.
This issue is probably JCC related, but I wanted to have your opinion first before posting on PyLucene's JIRA.
Cheers
Clément