-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.9.0: pytest is failing #64
Comments
I believe that this is https://tox.wiki/en/latest/example/pytest.html#known-issues-and-limitations. The issue is that the tests themselves are at both in the checkout and at the installed location. One fix is to explicitly pass the installed location as the directory to run tests from:
In a future version, we could move tests outside of the install path, which was probably a holdout from using the |
Gentle ping .. any update? 😄 |
Just tested new 0.9.1 and lokks like still somthing is wrong. + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1, configfile: pytest.ini
plugins: datadir-1.3.1, regressions-2.3.1, cov-3.0.0, httpserver-1.0.4, mock-3.7.0, asyncio-0.18.2
asyncio: mode=legacy
collected 158 items / 12 errors
================================================================================== ERRORS ==================================================================================
____________________________________________________________________ ERROR collecting kajiki/doctype.py ____________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.doctype', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/doctype.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/doctype.py'))
__________________________________________________________________ ERROR collecting kajiki/html_utils.py ___________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.html_utils', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/html_utils.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/html_utils.py'))
_____________________________________________________________________ ERROR collecting kajiki/i18n.py ______________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.i18n', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/i18n.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/i18n.py'))
______________________________________________________________________ ERROR collecting kajiki/ir.py _______________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.ir', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/ir.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/ir.py'))
____________________________________________________________________ ERROR collecting kajiki/lnotab.py _____________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.lnotab', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/lnotab.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/lnotab.py'))
____________________________________________________________________ ERROR collecting kajiki/loader.py _____________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.loader', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/loader.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/loader.py'))
________________________________________________________________ ERROR collecting kajiki/markup_template.py ________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.markup_template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/markup_template.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/markup_template.py'))
___________________________________________________________________ ERROR collecting kajiki/template.py ____________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/template.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/template.py'))
_____________________________________________________________________ ERROR collecting kajiki/text.py ______________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.text', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/text.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/text.py'))
_____________________________________________________________________ ERROR collecting kajiki/util.py ______________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.util', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/util.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/util.py'))
____________________________________________________________________ ERROR collecting kajiki/version.py ____________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.version', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/version.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/version.py'))
_________________________________________________________________ ERROR collecting kajiki/xml_template.py __________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('kajiki.xml_template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/xml_template.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1/kajiki/xml_template.py'))
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
ERROR kajiki/doctype.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.doctype', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python...
ERROR kajiki/html_utils.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.html_utils', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/...
ERROR kajiki/i18n.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.i18n', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/si...
ERROR kajiki/ir.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.ir', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-p...
ERROR kajiki/lnotab.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.lnotab', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3....
ERROR kajiki/loader.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.loader', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3....
ERROR kajiki/markup_template.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.markup_template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_6...
ERROR kajiki/template.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/pyth...
ERROR kajiki/text.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.text', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/si...
ERROR kajiki/util.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.util', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/si...
ERROR kajiki/version.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.version', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python...
ERROR kajiki/xml_template.py - _pytest.pathlib.ImportPathMismatchError: ('kajiki.xml_template', '/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 12 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================================================== 1 warning, 12 errors in 0.92s ======================================================================= That warning is possible to fix by patch --- a/pytest.ini~ 2022-04-20 20:06:22.000000000 +0000
+++ b/pytest.ini 2022-04-20 20:31:25.336739128 +0000
@@ -1,4 +1,5 @@
[pytest]
+asyncio_mode = auto
addopts =
--doctest-modules
--doctest-glob=*.rst |
Is the goal to test the copy in |
I think that I found solution. I've started pytest with + /usr/bin/pytest -ra --pyargs kajiki
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1, configfile: pytest.ini
plugins: asyncio-0.18.2
asyncio: mode=auto
collected 2 items / 1 error
================================================================================== ERRORS ==================================================================================
_________________________________________________________________ ERROR collecting integration/pyramid.py __________________________________________________________________
../../BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/kajiki/integration/pyramid.py:33: in <module>
from pyramid.interfaces import IRenderer, ITemplateRenderer
E ModuleNotFoundError: No module named 'pyramid'
========================================================================= short test summary info ==========================================================================
ERROR integration/pyramid.py - ModuleNotFoundError: No module named 'pyramid'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.73s ============================================================================= Looks like pytest,ini needs to be adjusted. |
I don't think you meant to use Perhaps you wanted to run |
Yep you are right. My mistake.
+ /usr/bin/pytest -ra tests
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1, configfile: pytest.ini
plugins: asyncio-0.18.2
asyncio: mode=auto
collected 154 items
tests/test_cli.py ........ [ 5%]
tests/test_doctype.py .. [ 6%]
tests/test_e2e.py .... [ 9%]
tests/test_ir.py ........ [ 14%]
tests/test_runtime.py ........ [ 19%]
tests/test_text.py ........................ [ 35%]
tests/test_xml.py .................................................................................................... [100%]
=========================================================================== 154 passed in 0.72s ============================================================================ So that works and it means that this test directory should be specified in pytest.ini to not force anyone to check where are the test units. |
So with final pytest.ini patch: --- a/pytest.ini~ 2022-04-20 20:06:22.000000000 +0000
+++ b/pytest.ini 2022-04-21 00:16:59.940514025 +0000
@@ -5,4 +5,6 @@
--ignore=speedtest.py
--ignore=release_new_version.py
--ignore=kajiki/integration/pyramid.py
+asyncio_mode = auto
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
+testpaths = tests it is possible to run pytest without any parameters + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1, configfile: pytest.ini, testpaths: tests
plugins: asyncio-0.18.2
asyncio: mode=auto
collected 154 items
tests/test_cli.py ........ [ 5%]
tests/test_doctype.py .. [ 6%]
tests/test_e2e.py .... [ 9%]
tests/test_ir.py ........ [ 14%]
tests/test_runtime.py ........ [ 19%]
tests/test_text.py ........................ [ 35%]
tests/test_xml.py .................................................................................................... [100%]
=========================================================================== 154 passed in 0.75s ============================================================================ |
Enabling --doctest-modules seems to cause the ImportPathMismatchError mentioned in Issue #64. The only two doctests in the modules can be found in doctype.py, and they don't seem to provide any additional coverage to what is already in test_doctype.py, therefore let's just disable them.
Does commit 6dd9edd work out for you? |
Tested. pytest found 4 units more. + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-kajiki-0.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/kajiki-0.9.1, configfile: pytest.ini
collected 158 items
README.rst . [ 0%]
docs/templating-basics.rst . [ 1%]
docs/text-templates.rst . [ 1%]
docs/xml-templates.rst . [ 2%]
tests/test_cli.py ........ [ 7%]
tests/test_doctype.py .. [ 8%]
tests/test_e2e.py .... [ 11%]
tests/test_ir.py ........ [ 16%]
tests/test_runtime.py ........ [ 21%]
tests/test_text.py ........................ [ 36%]
tests/test_xml.py .................................................................................................... [100%]
=========================================================================== 158 passed in 0.75s ============================================================================ I've removed |
Enabling --doctest-modules seems to cause the ImportPathMismatchError mentioned in Issue jackrosenthal#64. The only two doctests in the modules can be found in doctype.py, and they don't seem to provide any additional coverage to what is already in test_doctype.py, therefore let's just disable them.
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
I have alredy packaged almost 800 python modules ane to be honest I see first time such errors. Liooks like something is wrong with importing modules.
May I ask for some help?
Here is pytest output:
The text was updated successfully, but these errors were encountered: