Pytest: Fail doc/en/example/assertion/test_failures.py::test_failure_demo_fails_properly on python-2.7

Created on 1 Apr 2019  路  6Comments  路  Source: pytest-dev/pytest

  • [x ] Include a detailed description of the bug or suggestion
  • [ ] pip list of the virtual environment you are using
  • [x] pytest and operating system versions
  • [ ] Minimal example if possible

pytest-4.4.0, python-2.7 on openSUSE:Tumbleweed

pytest doc testsuite uses python 3.6 + syntax and fails on python2.7

  397s] _______________________ test_failure_demo_fails_properly _______________________
[  397s] 
[  397s] testdir = <Testdir local('/tmp/pytest-of-abuild/pytest-0/test_failure_demo_fails_properly0')>
[  397s] 
[  397s]     def test_failure_demo_fails_properly(testdir):
[  397s]         target = testdir.tmpdir.join(failure_demo.basename)
[  397s]         failure_demo.copy(target)
[  397s]         failure_demo.copy(testdir.tmpdir.join(failure_demo.basename))
[  397s]         result = testdir.runpytest(target, syspathinsert=True)
[  397s] >       result.stdout.fnmatch_lines(["*44 failed*"])
[  397s] E       Failed: nomatch: '*44 failed*'
[  397s] E           and: u'============================= test session starts =============================='
[  397s] E           and: u'platform linux2 -- Python 2.7.15, pytest-4.4.0, py-1.8.0, pluggy-0.9.0'
[  397s] E           and: u"hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/abuild/rpmbuild/BUILD/pytest-4.4.0/.hypothesis/examples')"
[  397s] E           and: u'rootdir: /tmp/pytest-of-abuild/pytest-0/test_failure_demo_fails_properly0'
[  397s] E           and: u'plugins: hypothesis-4.13.0'
[  397s] E           and: u'collected 0 items / 1 errors'
[  397s] E           and: u''
[  397s] E           and: u'==================================== ERRORS ===================================='
[  397s] E           and: u'_______________________ ERROR collecting failure_demo.py _______________________'
[  397s] E           and: u'/usr/lib/python2.7/site-packages/_pytest/python.py:511: in _importtestmodule'
[  397s] E           and: u'    mod = self.fspath.pyimport(ensuresyspath=importmode)'
[  397s] E           and: u'/usr/lib/python2.7/site-packages/py/_path/local.py:701: in pyimport'
[  397s] E           and: u'    __import__(modname)'
[  397s] E           and: u'E     File "/tmp/pytest-of-abuild/pytest-0/test_failure_demo_fails_properly0/failure_demo.py", line 106'
[  397s] E           and: u'E       a: int'
[  397s] E           and: u'E        ^'
[  397s] E           and: u'E   SyntaxError: invalid syntax'
[  397s] E           and: u'!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!'
[  397s] E           and: u'=========================== 1 error in 0.23 seconds ============================'
[  397s] E           and: u''
[  397s] E       remains unmatched: '*44 failed*'
[  397s] 
[  397s] /home/abuild/rpmbuild/BUILD/pytest-4.4.0/doc/en/example/assertion/test_failures.py:12: Failed
[  397s] ----------------------------- Captured stdout call -----------------------------
[  397s] ============================= test session starts ==============================
[  397s] platform linux2 -- Python 2.7.15, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
[  397s] hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/abuild/rpmbuild/BUILD/pytest-4.4.0/.hypothesis/examples')
[  397s] rootdir: /tmp/pytest-of-abuild/pytest-0/test_failure_demo_fails_properly0
[  397s] plugins: hypothesis-4.13.0
[  397s] collected 0 items / 1 errors
[  397s] 
[  397s] ==================================== ERRORS ====================================
[  397s] _______________________ ERROR collecting failure_demo.py _______________________
[  397s] /usr/lib/python2.7/site-packages/_pytest/python.py:511: in _importtestmodule
[  397s]     mod = self.fspath.pyimport(ensuresyspath=importmode)
[  397s] /usr/lib/python2.7/site-packages/py/_path/local.py:701: in pyimport
[  397s]     __import__(modname)
[  397s] E     File "/tmp/pytest-of-abuild/pytest-0/test_failure_demo_fails_properly0/failure_demo.py", line 106
[  397s] E       a: int
[  397s] E        ^
[  397s] E   SyntaxError: invalid syntax
[  397s] !!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
[  397s] =========================== 1 error in 0.23 seconds ============================
python 2 only bug infrastructure

Most helpful comment

Hi @mimi1vx, thanks for reporting.

Our tox -e doctesting runs on Python 3. I don't think we need to guarantee it running in Python 2 as well, because we want to use Python 3 syntax in our examples.

I propose we close as "won't fix".

All 6 comments

Not sure what to do about it - split it, or just skip it on py2?

At least in d52ea4b6 it was changed to use python3 explicitly for that reason.

Hi @mimi1vx, thanks for reporting.

Our tox -e doctesting runs on Python 3. I don't think we need to guarantee it running in Python 2 as well, because we want to use Python 3 syntax in our examples.

I propose we close as "won't fix".

@mimi1vx
How did you run into this btw? Is this for a distribution / packaging?
(testpaths is configured to only run tests from "testing/" by default)

@blueyed is distribution package, we preparing pytest4 for openSUSE

simply ran pytest-2.7 in pytest package dir with PYTHONPATH set to installed buildroot

But shouldn't that ignore the test, since only testing is used (via testpaths)?

Closing as wontfix.

Was this page helpful?
0 / 5 - 0 ratings