Closed kloczek closed 2 years ago
Probably pytest is somehow incompatible with tests in aioitertools. I use the following command to run tests:
python -m unittest -v aioitertools.tests
Don't get me wong but I'm tryuing to standarise all my packahhes with python modules arounfd use pytest on test suite execution.
[tkloczko@devel-g2v SPECS]$ grep ^%pytest python-* | wc -l; ls -1 python-*|wc -l
1002
1024
as you see I've been able to use that methodology with +98% of all my packages with python modules.
Other issue in latest version is that aioitertools/tests content is installed. Test suite should not be installed.
I made anotehr experiment:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-aioitertools-0.10.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-aioitertools-0.10.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra aioitertools/tests/*py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/aioitertools-0.10.0
collected 127 items
aioitertools/tests/asyncio.py ............. [ 10%]
aioitertools/tests/builtins.py ..................................... [ 39%]
aioitertools/tests/helpers.py ..... [ 43%]
aioitertools/tests/itertools.py ................................................................. [ 94%]
aioitertools/tests/more_itertools.py ....... [100%]
============================================================================= warnings summary =============================================================================
aioitertools/tests/helpers.py::HelpersTest::test_maybe_await_coroutine
/home/tkloczko/rpmbuild/BUILD/aioitertools-0.10.0/aioitertools/tests/helpers.py:43: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def forty_two():
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================================== 127 passed, 1 warning in 2.47s ======================================================================
So clearly looks like some bits are missing ..
Interesting! Looks like pytest only considers test_*.py
or *_test.py
files, and aioitertools does not use such filenames. Maybe it's good to switch to such filenames - it's up to maintainers, anyway.
See: https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#test-discovery
Good catch .. I was not awate of tjat 😋 So probably raname files in tests/ should fix that ..
And pleass add to exclude tests/ content on assemmbly .whl 😋
I'm sorry, but I don't plan to do either of these. I don't use pytest, and I don't like its insistence on using repetitive naming schemes for everything. The official way to run the test suite is via the stdlib unittest module, as yan mentioned above. You are free to use pytest if you like, or any other testing framework, but that's up to you to make that work with the project; it looks like you already found a way to make it run the test suite as-is.
I likewise have no plans to remove the test suite from the wheels. They are useful for validating the package's functionality after installation, and they are intentionally inside the main package's namespace so that they don't conflict with any other package. They are also small enough that I see no meaningful benefit from leaving them out. Distro packaging systems are free to remove them if they want, but they can't easily be added back in by users who do want to have them.
FYI: corectly written unittest test suite can be correcrly handled by pytest. Is is really so bad to rename few fiels? 🤔
In source tree I see aioitertools/tests/ and despite that pytest is not able to find any units