Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 614126 - dev-python/pytest-3.0.3 fails tests ( test_multiple_items_per_collector_byid : acceptance_test.py:258: AssertionError, AttributeError: 'MyItem' object has no attribute 'module' )
Summary: dev-python/pytest-3.0.3 fails tests ( test_multiple_items_per_collector_byid ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: TESTFAILURE
Depends on:
Blocks:
 
Reported: 2017-03-28 08:41 UTC by Kent Fredric (IRC: kent\n) (RETIRED)
Modified: 2019-01-27 13:46 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,328.48 KB, text/plain)
2017-03-28 08:41 UTC, Kent Fredric (IRC: kent\n) (RETIRED)
Details
emerge --info (einfo,5.09 KB, text/plain)
2017-03-28 08:42 UTC, Kent Fredric (IRC: kent\n) (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-03-28 08:41:27 UTC
Created attachment 468502 [details]
build.log

First failure:


===================================================================================================================================== FAILURES ======================================================================================================================================
______________________________________________________________________________________________________________ TestGeneralUsage.test_multiple_items_per_collector_byid ______________________________________________________________________________________________________________

self = <acceptance_test.TestGeneralUsage instance at 0x7ff71f063998>, testdir = <Testdir local('/var/tmp/portage/dev-python/pytest-3.0.3/temp/pytest-of-portage/pytest-0/testdir/test_multiple_items_per_collector_byid0')>

    def test_multiple_items_per_collector_byid(self, testdir):
        c = testdir.makeconftest("""
                import pytest
                class MyItem(pytest.Item):
                    def runtest(self):
                        pass
                class MyCollector(pytest.File):
                    def collect(self):
                        return [MyItem(name="xyz", parent=self)]
                def pytest_collect_file(path, parent):
                    if path.basename.startswith("conftest"):
                        return MyCollector(path, parent)
            """)
        result = testdir.runpytest(c.basename+"::"+"xyz")
>       assert result.ret == 0
E       assert 3 == 0
E        +  where 3 = <_pytest.pytester.RunResult instance at 0x7ff71eed7128>.ret

../../../../../work/pytest-3.0.3/testing/acceptance_test.py:258: AssertionError
------------------------------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------------------------------
================================================================================================================================ test session starts ================================================================================================================================
platform linux2 -- Python 2.7.12, pytest-3.0.3, py-1.4.30, pluggy-0.4.0
rootdir: /var/tmp/portage/dev-python/pytest-3.0.3/temp/pytest-of-portage/pytest-0/testdir/test_multiple_items_per_collector_byid0, inifile: 
plugins: xdist-1.15.0, hypothesis-3.6.0, flaky-3.1.1
collected 2 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/main.py", line 96, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/main.py", line 131, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 302, in __call__
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 280, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 300, in <lambda>
INTERNALERROR>     outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/main.py", line 152, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 302, in __call__
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 280, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 300, in <lambda>
INTERNALERROR>     outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 280, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/var/tmp/portage/dev-python/pytest-3.0.3/work/pytest-3.0.3-python2_7/lib/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/lib64/python2.7/site-packages/flaky/flaky_pytest_plugin.py", line 68, in pytest_runtest_protocol
INTERNALERROR>     self._copy_flaky_attributes(item, test_instance)
INTERNALERROR>   File "/usr/lib64/python2.7/site-packages/flaky/_flaky_plugin.py", line 404, in _copy_flaky_attributes
INTERNALERROR>     _, test_callable, _ = cls._get_test_declaration_callable_and_name(test)
INTERNALERROR>   File "/usr/lib64/python2.7/site-packages/flaky/flaky_pytest_plugin.py", line 360, in _get_test_declaration_callable_and_name
INTERNALERROR>     elif hasattr(test.module, callable_name):
INTERNALERROR> AttributeError: 'MyItem' object has no attribute 'module'

=========================================================================================================================== no tests ran in 0.01 seconds ============================================================================================================================
Comment 1 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-03-28 08:42:49 UTC
Created attachment 468504 [details]
emerge --info
Comment 2 Maram 2017-12-31 15:36:47 UTC
The reason for this error is a combination of pytest and the flaky plugin.
For the cited error pytest is too new and flaky is too old, with flaky-3.4.0 and pytest 3.2.2 these errors are gone.
(commits 1d41ec11f51dee4e62cbc239f59eceb7f031a4c1 and part of 9b1f9e3c1d818350666513437892f04196d7c0e3 of the flaky repository [0] (included in flaky >=3.2.0)) See upstream issues [1,2].

However, this does not fix the complete test suite of >=pytest-3. There are still tests which fail due to flaky generating additional output for tests:
===Flaky Test Report===

===End Flaky Test Report===
(even though this is a complete empty report)

We can deactivate a plugin in pytest using "pytest -p no:flaky" in the ebuild but that does not help as the pytest instance run from within the pytest test suite produces the additional output and this doesn't get the "-p no:flaky" parameter passed on from the initial invocation. There also seems to be no mechanism to deactivate pytest plugins by default...

HTH
maram

[0] https://github.com/box/flaky
[1] https://github.com/box/flaky/issues/99
[2] https://github.com/box/flaky/issues/101
Comment 3 Virgil Dupras (RETIRED) gentoo-dev 2019-01-27 13:46:19 UTC
flaky has been blocked in pytest's dependencies for a while now. Closing.