Skip to content
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

deprecation exceptions not displayed in pytester #6083

Open
RonnyPfannschmidt opened this issue Oct 27, 2019 · 4 comments
Open

deprecation exceptions not displayed in pytester #6083

RonnyPfannschmidt opened this issue Oct 27, 2019 · 4 comments
Labels
plugin: pytester related to the pytester builtin plugin

Comments

@RonnyPfannschmidt
Copy link
Member

RonnyPfannschmidt commented Oct 27, 2019

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 ===============================================================================================================
@blueyed
Copy link
Contributor

blueyed commented Oct 27, 2019

What do you mean?

There is e.g.

pytest.PytestDeprecationWarning: direct construction of Session has been deprecated, please use Session.from_parent

@RonnyPfannschmidt
Copy link
Member Author

@blueyed those are unrelated and wil lbe fixed, as mentioned, i will update the output in a bit

@RonnyPfannschmidt
Copy link
Member Author

cut down, based on the traceback content its evident that a ctor mechanism that should warn is used, but the warnings don't print/fail, instead nothing is there

@blueyed
Copy link
Contributor

blueyed commented Oct 27, 2019

Still not sure what you mean.. but I've seen some wrongly cut things when e.g. internal generators were involved. Sounds like a bug in _prunetrackback (related: blueyed@df641ab#diff-88cb3736bed2f144d42f07ccbeb97eb0R793).

@Zac-HD Zac-HD added the plugin: pytester related to the pytester builtin plugin label Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: pytester related to the pytester builtin plugin
Projects
None yet
Development

No branches or pull requests

3 participants