Skip to content

deprecation exceptions not displayed in pytester #6083

@RonnyPfannschmidt

Description

@RonnyPfannschmidt

found while making #5975

traceback still has some fixable unrelated items that i will sort out

===================================================================================================================== test session starts ======================================================================================================================
platform linux -- Python 3.7.4, pytest-4.6.1.dev635+gfca462cf7, py-1.8.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/rpfannsc/Projects/pytest-dev/pytest/.hypothesis/examples')
rootdir: /home/rpfannsc/Projects/pytest-dev/pytest, inifile: tox.ini, testpaths: testing
plugins: hypothesis-4.39.0
collected 603 items / 600 deselected / 3 selected                                                                                                                                                                                                              
run-last-failure: rerun previous 3 failures (skipped 57 files)

testing/test_collection.py F                                                                                                                                                                                                                             [ 33%]
testing/python/collect.py F                                                                                                                                                                                                                              [ 66%]
testing/python/integration.py F                                                                                                                                                                                                                          [100%]

=========================================================================================================================== FAILURES ===========================================================================================================================
__________________________________________________________________________________________________________ TestCollector.test_getcustomfile_roundtrip __________________________________________________________________________________________________________

self = <test_collection.TestCollector object at 0x7f2120843810>, testdir = <Testdir local('/tmp/pytest-of-rpfannsc/pytest-11/test_getcustomfile_roundtrip0')>

    def test_getcustomfile_roundtrip(self, testdir):
        hello = testdir.makefile(".xxx", hello="world")
        testdir.makepyfile(
            conftest="""
            import pytest
            class CustomFile(pytest.File):
                pass
            def pytest_collect_file(path, parent):
                if path.ext == ".xxx":
                    return CustomFile(path, parent=parent)
        """
        )
>       node = testdir.getpathnode(hello)

/home/rpfannsc/Projects/pytest-dev/pytest/testing/test_collection.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Testdir local('/tmp/pytest-of-rpfannsc/pytest-11/test_getcustomfile_roundtrip0')>, path = local('/tmp/pytest-of-rpfannsc/pytest-11/test_getcustomfile_roundtrip0/hello.xxx')

    def getpathnode(self, path):
        """Return the collection node of a file.
    
        This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to
        create the (configured) pytest Config instance.
    
        :param path: a :py:class:`py.path.local` instance of the file
    
        """
        config = self.parseconfigure(path)
        session = Session.from_config(config)
        x = session.fspath.bestrelpath(path)
        config.hook.pytest_sessionstart(session=session)
>       res = session.perform_collect([x], genitems=False)[0]
E       IndexError: list index out of range

/home/rpfannsc/Projects/pytest-dev/pytest/src/_pytest/pytester.py:714: IndexError
--------------------------------------------------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-4.6.1.dev635+gfca462cf7, py-1.8.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/rpfannsc/Projects/pytest-dev/pytest/.hypothesis/examples')
rootdir: /tmp/pytest-of-rpfannsc/pytest-11/test_getcustomfile_roundtrip0
plugins: hypothesis-4.39.0
collected 0 items / 1 errors
__________________________________________________________________________________________________________ TestReportInfo.test_itemreport_reportinfo ___________________________________________________________________________________________________________

self = <collect.TestReportInfo object at 0x7f21201f0e90>, testdir = <Testdir local('/tmp/pytest-of-rpfannsc/pytest-11/test_itemreport_reportinfo0')>, linecomp = <_pytest.pytester.LineComp object at 0x7f21201e3f90>

    def test_itemreport_reportinfo(self, testdir, linecomp):
        testdir.makeconftest(
            """
            import pytest
            class MyFunction(pytest.Function):
                def reportinfo(self):
                    return "ABCDE", 42, "custom"
            def pytest_pycollect_makeitem(collector, name, obj):
                if name == "test_func":
                    return MyFunction(name, parent=collector)
        """
        )
>       item = testdir.getitem("def test_func(): pass")

/home/rpfannsc/Projects/pytest-dev/pytest/testing/python/collect.py:1030: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Testdir local('/tmp/pytest-of-rpfannsc/pytest-11/test_itemreport_reportinfo0')>, source = 'def test_func(): pass', funcname = 'test_func'

    def getitem(self, source, funcname="test_func"):
        """Return the test item for a test function.
    
        This writes the source to a python file and runs pytest's collection on
        the resulting module, returning the test item for the requested
        function name.
    
        :param source: the module source
    
        :param funcname: the name of the test function for which to return a
            test item
    
        """
        items = self.getitems(source)
        for item in items:
            if item.name == funcname:
                return item
>       assert 0, "{!r} item not found in module:\n{}\nitems: {}".format(
            funcname, source, items
        )
E       AssertionError: 'test_func' item not found in module:
E         def test_func(): pass
E         items: []
E       assert 0

/home/rpfannsc/Projects/pytest-dev/pytest/src/_pytest/pytester.py:954: AssertionError
--------------------------------------------------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-4.6.1.dev635+gfca462cf7, py-1.8.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/rpfannsc/Projects/pytest-dev/pytest/.hypothesis/examples')
rootdir: /tmp/pytest-of-rpfannsc/pytest-11/test_itemreport_reportinfo0
plugins: hypothesis-4.39.0
collected 0 items

============================ no tests ran in 0.00s =============================
______________________________________________________________________________________________________ TestOEJSKITSpecials.test_funcarg_non_pycollectobj _______________________________________________________________________________________________________

self = <integration.TestOEJSKITSpecials object at 0x7f21201f0d90>, testdir = <Testdir local('/tmp/pytest-of-rpfannsc/pytest-11/test_funcarg_non_pycollectobj0')>

    def test_funcarg_non_pycollectobj(self, testdir):  # rough jstests usage
        testdir.makeconftest(
            """
            import pytest
            def pytest_pycollect_makeitem(collector, name, obj):
                if name == "MyClass":
                    return MyCollector(name, parent=collector)
            class MyCollector(pytest.Collector):
                def reportinfo(self):
                    return self.fspath, 3, "xyz"
        """
        )
        modcol = testdir.getmodulecol(
            """
            import pytest
            @pytest.fixture
            def arg1(request):
                return 42
            class MyClass(object):
                pass
        """
        )
        # this hook finds funcarg factories
        rep = runner.collect_one_node(collector=modcol)
>       clscol = rep.result[0]
E       IndexError: list index out of range

/home/rpfannsc/Projects/pytest-dev/pytest/testing/python/integration.py:31: IndexError
--------------------------------------------------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-4.6.1.dev635+gfca462cf7, py-1.8.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/rpfannsc/Projects/pytest-dev/pytest/.hypothesis/examples')
rootdir: /tmp/pytest-of-rpfannsc/pytest-11/test_funcarg_non_pycollectobj0
plugins: hypothesis-4.39.0
collected 0 items

============================ no tests ran in 0.00s =============================
=================================================================================================================== short test summary info ====================================================================================================================
FAILED testing/test_collection.py::TestCollector::test_getcustomfile_roundtrip - IndexError: list index out of range
FAILED testing/python/collect.py::TestReportInfo::test_itemreport_reportinfo - AssertionError: 'test_func' item not found in module:
FAILED testing/python/integration.py::TestOEJSKITSpecials::test_funcarg_non_pycollectobj - IndexError: list index out of range
============================================================================================================== 3 failed, 600 deselected in 0.65s ===============================================================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: pytesterrelated to the pytester builtin plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions