Open SoapGentoo opened 8 years ago
@SoapGentoo the very test that is failing is creating those modules as part of an end to end test of pytest
its not clear why this happens at first glance
@SoapGentoo the test itself also has code in place to add things to pythonpath - does gentoo pass anything special to the testing process/apply patches to python/pytest/pylib?
@RonnyPfannschmidt Gentoo just calls
"${PYTHON}" "${BUILD_DIR}"/lib/pytest.py -x -v --runpytest=subprocess
where ${PYTHON}
contains something like python2.7 for instance.
Anything new related to this issue?
This is reproducible:
$ pytest testing/python/fixture.py -k test_non_relative_path --runpytest=subprocess
============================= test session starts ==============================
platform linux -- Python 3.6.5, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /tmp/t/pytest, inifile: tox.ini
plugins: hypothesis-3.66.0
collected 175 items / 174 deselected
testing/python/fixture.py F [100%]
=================================== FAILURES ===================================
______________ TestParameterizedSubRequest.test_non_relative_path ______________
self = <fixture.TestParameterizedSubRequest object at 0x7f7e0e95be80>
testdir = <Testdir local('/tmp/pytest-of-asottile/pytest-2/test_non_relative_path0')>
def test_non_relative_path(self, testdir):
tests_dir = testdir.mkdir("tests")
fixdir = testdir.mkdir("fixtures")
fixfile = fixdir.join("fix.py")
fixfile.write(
_pytest._code.Source(
"""
import pytest
@pytest.fixture(params=[0, 1, 2])
def fix_with_param(request):
return request.param
"""
)
)
testfile = tests_dir.join("test_foos.py")
testfile.write(
_pytest._code.Source(
"""
from fix import fix_with_param
def test_foo(request):
request.getfixturevalue('fix_with_param')
"""
)
)
tests_dir.chdir()
testdir.syspathinsert(fixdir)
result = testdir.runpytest()
result.stdout.fnmatch_lines(
"""
E*Failed: The requested fixture has no parameter defined for the current test.
E*
E*Requested fixture 'fix_with_param' defined in:
E*{}:5
E*Requested here:
E*{}:5
*1 failed*
""".format(
> fixfile.strpath, testfile.basename
)
)
/tmp/t/pytest/testing/python/fixture.py:3741:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.pytester.LineMatcher object at 0x7f7e0e94f358>
lines2 = '\n E*Failed: The requested fixture has no parameter defined for the current test.\n E*\n ...0/fixtures/fix.py:5\n E*Requested here:\n E*test_foos.py:5\n *1 failed*\n '
def fnmatch_lines(self, lines2):
"""Search captured text for matching lines using ``fnmatch.fnmatch``.
The argument is a list of lines which have to match and can use glob
wildcards. If they do not match a pytest.fail() is called. The
matches and non-matches are also printed on stdout.
"""
> self._match_lines(lines2, fnmatch, "fnmatch")
E Failed: nomatch: 'E*Failed: The requested fixture has no parameter defined for the current test.'
E and: '============================= test session starts =============================='
E and: 'platform linux -- Python 3.6.5, pytest-3.6.3, py-1.5.4, pluggy-0.6.0'
E and: 'rootdir: /tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/tests, inifile:'
E and: 'plugins: hypothesis-3.66.0'
E and: 'collected 0 items / 1 errors'
E and: ''
E and: '==================================== ERRORS ===================================='
E and: '________________________ ERROR collecting test_foos.py _________________________'
E and: "ImportError while importing test module '/tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/tests/test_foos.py'."
E and: 'Hint: make sure your test modules/packages have valid Python names.'
E and: 'Traceback:'
E and: 'test_foos.py:2: in <module>'
E and: ' from fix import fix_with_param'
E and: "E ModuleNotFoundError: No module named 'fix'"
E and: '!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!'
E and: '=========================== 1 error in 0.09 seconds ============================'
E remains unmatched: 'E*Failed: The requested fixture has no parameter defined for the current test.'
/tmp/t/venv/lib/python3.6/site-packages/_pytest/pytester.py:1216: Failed
----------------------------- Captured stdout call -----------------------------
running: /tmp/t/venv/bin/python3 /tmp/t/venv/lib/python3.6/site-packages/pytest.py --basetemp=/tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/runpytest-0 --basetemp=/tmp/pytest-of-asottile/pytest-2/basetemp
in: /tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/tests
============================= test session starts ==============================
platform linux -- Python 3.6.5, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/tests, inifile:
plugins: hypothesis-3.66.0
collected 0 items / 1 errors
==================================== ERRORS ====================================
________________________ ERROR collecting test_foos.py _________________________
ImportError while importing test module '/tmp/pytest-of-asottile/pytest-2/test_non_relative_path0/tests/test_foos.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_foos.py:2: in <module>
from fix import fix_with_param
E ModuleNotFoundError: No module named 'fix'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.09 seconds ============================
=========================== short test summary info ============================
FAIL testing/python/fixture.py::TestParameterizedSubRequest::()::test_non_relative_path
=================== 1 failed, 174 deselected in 0.68 seconds ===================
The pytester
subprocess approach does not propagate the in-process modifications to sys.path
. @SoapGentoo is there a reason to run with --runpytest=subprocess
?
Closing as this has not seen activity in awhile.
:(
We should have a look at enabling the subprocess stuff for a job in ci
I can still reproduce this with pytest testing/python/fixtures.py -k test_non_relative_path --runpytest=subprocess
. Given that we have a global --runpytest=subprocess
switch, I think it's fair to assume that pytest's own testsuite should work with it.
I'm trying to package pytest 3.0.1 for Gentoo. During the test run, I get the following error:
For more details, see the Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=592424
I've searched the whole internet, and found no reference to a python module with name fix and function fix_with_param. What am I doing wrong? Which dependency am I missing?