Closed kloczek closed 2 years ago
I get the same error if I apply this diff to the project and run tests with tox:
tempora main $ git diff
diff --git a/setup.cfg b/setup.cfg
index d29a911..7c70a7c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -45,7 +45,6 @@ testing =
# local
backports.unittest_mock
freezegun
- pytest-freezegun
types-freezegun
types-pytz
I also get the error if I run the tests with tox -- -p no:freezegun
.
That leads me to believe that for whatever reason, your build environment isn't including all of the test dependencies (pytest-freezegun in particular) or somehow the metadata from those packages is missing.
I notice in your pytest output, none of the plugins are loaded. I expect to see something like:
============================================================= test session starts =============================================================
platform darwin -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
cachedir: .tox/python/.pytest_cache
rootdir: /Users/jaraco/code/main/tempora, configfile: pytest.ini
plugins: flake8-1.0.7, enabler-1.2.1, backports.unittest-mock-1.5, freezegun-0.4.2, checkdocs-2.7.1, black-0.3.12, mypy-0.8.1, cov-3.0.0
Since there are no plugins in your output, my suspicion is that either the test requirements haven't been installed or they've not been installed with the necessary metadata. I'd expect you to see something like this:
python -c "import importlib.metadata as md; import pprint; pprint.pprint(md.entry_points()['pytest11'])"
<string>:1: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
[EntryPoint(name='flake8', value='pytest_flake8', group='pytest11'),
EntryPoint(name='plugin-enabled options', value='pytest_enabler', group='pytest11'),
EntryPoint(name='unittest_mock', value='backports.unittest_mock', group='pytest11'),
EntryPoint(name='freezegun', value='pytest_freezegun', group='pytest11'),
EntryPoint(name='checkdocs', value='pytest_checkdocs', group='pytest11'),
EntryPoint(name='black', value='pytest_black', group='pytest11'),
EntryPoint(name='mypy', value='pytest_mypy', group='pytest11'),
EntryPoint(name='pytest_cov', value='pytest_cov.plugin', group='pytest11')]
If the packages aren't installed, you'll want to install them. If they are installed, you'll want to investigate why their associated "dist-info" directories are missing.
Just tested 5.0.0 and all looks good
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -p no:flake8 --deselect tempora/__init__.py::tempora.get_nearest_year_for_day
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/tempora-5.0.0, configfile: pytest.ini
collected 42 items / 1 deselected / 41 selected
tempora/__init__.py ........... [ 26%]
tempora/schedule.py ... [ 34%]
tempora/timing.py ..... [ 46%]
tempora/utc.py . [ 48%]
tempora/tests/test_schedule.py ................... [ 95%]
tempora/tests/test_timing.py .. [100%]
===================================================================== 41 passed, 1 deselected in 1.53s =====================================================================
Nope .. sorry. Forgot do deselect previously failing unit :/
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/tempora-5.0.0, configfile: pytest.ini
plugins: flake8-1.0.7
collected 42 items
tempora/__init__.py .......F.... [ 28%]
tempora/schedule.py ... [ 35%]
tempora/timing.py ..... [ 47%]
tempora/utc.py . [ 50%]
tempora/tests/test_schedule.py ................... [ 95%]
tempora/tests/test_timing.py .. [100%]
================================================================================= FAILURES =================================================================================
________________________________________________________________ [doctest] tempora.get_nearest_year_for_day ________________________________________________________________
203
204 Returns the nearest year to now inferred from a Julian date.
205
206 >>> freezer = getfixture('freezer')
UNEXPECTED EXCEPTION: FixtureLookupError('freezer', <FixtureRequest for <DoctestItem tempora.get_nearest_year_for_day>>)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/_pytest/fixtures.py", line 589, in _get_active_fixturedef
return self._fixture_defs[argname]
KeyError: 'freezer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.8/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest tempora.get_nearest_year_for_day[0]>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/_pytest/fixtures.py", line 581, in getfixturevalue
fixturedef = self._get_active_fixturedef(argname)
File "/usr/lib/python3.8/site-packages/_pytest/fixtures.py", line 592, in _get_active_fixturedef
fixturedef = self._getnextfixturedef(argname)
File "/usr/lib/python3.8/site-packages/_pytest/fixtures.py", line 473, in _getnextfixturedef
raise FixtureLookupError(argname, self)
_pytest.fixtures.FixtureLookupError: ('freezer', <FixtureRequest for <DoctestItem tempora.get_nearest_year_for_day>>)
/home/tkloczko/rpmbuild/BUILD/tempora-5.0.0/tempora/__init__.py:206: UnexpectedException
========================================================================= short test summary info ==========================================================================
FAILED tempora/__init__.py::tempora.get_nearest_year_for_day
======================================================================= 1 failed, 41 passed in 1.53s =======================================================================
Please see my analysis - the issue remains the same - a test dependency pytest-freezegun
is missing.
Error message was misleading. With installed pytest-frezgun
pytest is OK 😄
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-tempora-5.0.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/tempora-5.0.1, configfile: pytest.ini
plugins: flaky-3.7.0, forked-1.4.0, shutil-1.7.0, cov-3.0.0, virtualenv-1.7.0, flake8-1.0.7, xdist-2.5.0, checkdocs-2.7.1, freezegun-0.4.2
collected 45 items
. . [ 2%]
tempora/__init__.py ............ [ 30%]
tempora/schedule.py ... [ 37%]
tempora/timing.py ..... [ 48%]
tempora/utc.py . [ 51%]
tempora/tests/test_schedule.py ................... [ 95%]
tempora/tests/test_timing.py .. [100%]
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/pytest_freezegun.py:17: 86 warnings
tempora/__init__.py: 2 warnings
/usr/lib/python3.8/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):
-- Docs: https://docs.pytest.org/en/stable/warnings.html
===================================================================== 43 passed, 88 warnings in 8.25s ======================================================================
Feel free to close this tisket if you are OK about above pytet warning.
Thank you.
Closing.
Gosh .. that warning is in pytest-freezegun
code 😄
I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes oly locally installed modulesHere is pytest output:
List of modules installed in build env: