3.0.0: pytest is failing in `tests/test_functional.py::test_modules_not_importable_unittest`unit
kloczek opened this issue · comments
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
- install .whl file in </install/prefix>
- run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sybil-3.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sybil-3.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -q
=========================================================================== 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/sybil-3.0.0, configfile: setup.cfg
plugins: cov-3.0.0
collected 112 items
docs/example-skip.rst ......... [ 8%]
docs/example.rst .... [ 11%]
docs/parsers.rst .................. [ 27%]
tests/test_capture.py .... [ 31%]
tests/test_codeblock.py .......... [ 40%]
tests/test_doc_example.py .. [ 41%]
tests/test_doctest.py ........ [ 49%]
tests/test_functional.py .............................F.. [ 77%]
tests/test_helpers.py .. [ 79%]
tests/test_skip.py .... [ 83%]
tests/test_sybil.py ................... [100%]
================================================================================= FAILURES =================================================================================
___________________________________________________________________ test_modules_not_importable_unittest ___________________________________________________________________
tmpdir = local('/tmp/pytest-of-tkloczko/pytest-275/test_modules_not_importable_un0'), capsys = <_pytest.capture.CaptureFixture object at 0x7fd94b9d6670>
def test_modules_not_importable_unittest(tmpdir: local, capsys: CaptureFixture[str]):
# NB: no append to sys.path
results = clone_and_run_modules_tests(tmpdir, capsys, UNITTEST)
assert results.total == 5, results.out.text
assert results.failures == 0, results.out.text
assert results.errors == 5, results.out.text
a_py = tmpdir/'modules'/'a.py'
b_py = tmpdir/'modules'/'b.py'
out = results.out
out.then_find(f'ERROR: {a_py},line:3,column:1')
out.then_find(f"ImportError: 'a' not importable from {tmpdir/'modules'/'a.py'} as:")
out.then_find("ModuleNotFoundError: No module named 'a'")
> out.then_find(f'ERROR: {b_py},line:2,column:1')
tests/test_functional.py:329:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.helpers.Finder object at 0x7fd94d764af0>, substring = 'ERROR: /tmp/pytest-of-tkloczko/pytest-275/test_modules_not_importable_un0/modules/b.py,line:2,column:1'
def then_find(self, substring):
> assert substring in self.text[self.index:], self.text[self.index:]
E AssertionError: ModuleNotFoundError: No module named 'a'
E
E ======================================================================
E ERROR: /tmp/pytest-of-tkloczko/pytest-275/test_modules_not_importable_un0/modules/a.py,line:7,column:1
E ----------------------------------------------------------------------
E Traceback (most recent call last):
E File "/home/tkloczko/rpmbuild/BUILD/sybil-3.0.0/sybil/integration/unittest.py", line 17, in runTest
E self.example.evaluate()
E File "/home/tkloczko/rpmbuild/BUILD/sybil-3.0.0/sybil/example.py", line 64, in evaluate
E result = evaluator(self)
E File "/home/tkloczko/rpmbuild/BUILD/sybil-3.0.0/sybil/document.py", line 142, in evaluator
E module = import_path(Path(example.path))
E File "/home/tkloczko/rpmbuild/BUILD/sybil-3.0.0/sybil/python.py", line 40, in import_path
E raise ImportError(
E ImportError: 'a' not importable from /tmp/pytest-of-tkloczko/pytest-275/test_modules_not_importable_un0/modules/a.py as:
E ModuleNotFoundError: No module named 'a'
E
E ----------------------------------------------------------------------
E Ran 5 tests in 0.006s
E
E FAILED (errors=5)
tests/helpers.py:67: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED tests/test_functional.py::test_modules_not_importable_unittest - AssertionError: ModuleNotFoundError: No module named 'a'
====================================================================== 1 failed, 111 passed in 2.53s =======================================================================
Please can you run the tests in the same way the CI does. I'm closing this issue as I'm frankly bored with people messing up building packages for linux distributions:
https://github.com/simplistix/sybil/issues?q=label%3Alinux-distro-packaging
If you can find a solution to the problem you have manufactured, please submit a PR.
I see this isn't the first python repo you've done this too: testing-cabal/linecache2#17
Perhaps you could indicate in the title of issues you submit that you're attempting to build a linux distro package?
Oh, looks like you're a serial abuser of Python packages:
pypa/flit#491
sqlalchemy/sqlalchemy#7441
numpy/numpy#20264
Perhaps you could just stop?
I see this isn't the first python repo you've done this too: testing-cabal/linecache2#17 Perhaps you could indicate in the title of issues you submit that you're attempting to build a linux distro package?
I've done that in first sentence of this ticket. Quoting:
I'm trying to package your module as an rpm package.
Oh, looks like you're a serial abuser of Python packages
I've already packaged +800 modules with rigorous testing.
On that scale it is obvious they it is possible to stump few times a day on some issue.
Why do you think that I should not share what I'm able to find?