Skip to content

why can't I debug this one test in the pytest testsuite? #4442

@asottile

Description

@asottile

Tried several hundred commits back and I can't debug it there either. I'm a bit perplexed

Apply this patch:

diff --git a/testing/python/collect.py b/testing/python/collect.py
index de40486a..e66bfafe 100644
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -288,6 +288,7 @@ class TestGenerator(object):
         assert len(colitems) == 1
         gencol = colitems[0]
         assert isinstance(gencol, pytest.Generator)
+        import pdb; pdb.set_trace()
         pytest.raises(ValueError, "gencol.collect()")
 
     def test_generative_methods_with_explicit_names(self, testdir):

(git apply, then paste, then ^D)

And then run this command: pytest testing/python/collect.py -k test_generative_functions_unique_explicit_names

$ pytest testing/python/collect.py -k test_generative_functions_unique_explicit_names
============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-4.0.0, py-1.7.0, pluggy-0.8.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/pytest/.hypothesis/examples')
rootdir: /tmp/pytest, inifile: tox.ini
plugins: hypothesis-3.82.1
collected 79 items / 78 deselected                                             

testing/python/collect.py F                                              [100%]

=================================== FAILURES ===================================
________ TestGenerator.test_generative_functions_unique_explicit_names _________

self = <collect.TestGenerator object at 0x7fad57621eb8>
testdir = <Testdir local('/tmp/pytest-of-asottile/pytest-15/test_generative_functions_unique_explicit_names0')>

    def test_generative_functions_unique_explicit_names(self, testdir):
        # generative
        modcol = testdir.getmodulecol("""
            def func(): pass
            def test_gen():
                yield "name", func
                yield "name", func
        """)
        colitems = modcol.collect()
        assert len(colitems) == 1
        gencol = colitems[0]
        assert isinstance(gencol, pytest.Generator)
        import pdb; pdb.set_trace()
>       pytest.raises(ValueError, "gencol.collect()")

/tmp/pytest/testing/python/collect.py:292: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/tmp/pytest/testing/python/collect.py:292: in test_generative_functions_unique_explicit_names
    pytest.raises(ValueError, "gencol.collect()")
/usr/lib/python3.6/bdb.py:51: in trace_dispatch
    return self.dispatch_line(frame)
/usr/lib/python3.6/bdb.py:69: in dispatch_line
    self.user_line(frame)
/usr/lib/python3.6/pdb.py:261: in user_line
    self.interaction(frame, None)
/usr/lib/python3.6/pdb.py:352: in interaction
    self._cmdloop()
/usr/lib/python3.6/pdb.py:321: in _cmdloop
    self.cmdloop()
/usr/lib/python3.6/cmd.py:126: in cmdloop
    line = input(self.prompt)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.capture.DontReadFromInput object at 0x7fad57749278>, args = ()

    def read(self, *args):
>       raise IOError("reading from stdin while output is captured")
E       OSError: reading from stdin while output is captured

/tmp/pytest/venv/lib/python3.6/site-packages/_pytest/capture.py:653: OSError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-4.0.0, py-1.7.0, pluggy-0.8.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/pytest/.hypothesis/examples')
rootdir: /tmp/pytest-of-asottile/pytest-15/test_generative_functions_unique_explicit_names0, inifile:
plugins: hypothesis-3.82.1
collected 0 items

=============================== warnings summary ===============================
/tmp/pytest/venv/lib/python3.6/site-packages/_pytest/assertion/rewrite.py:272
  /tmp/pytest/venv/lib/python3.6/site-packages/_pytest/assertion/rewrite.py:272: PytestWarning: Module already imported so cannot be rewritten: hypothesis
    self.config,

-- Docs: https://docs.pytest.org/en/latest/warnings.html
========================== 1 warnings in 0.00 seconds ==========================

>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>
> /tmp/pytest/testing/python/collect.py(292)test_generative_functions_unique_explicit_names()
-> pytest.raises(ValueError, "gencol.collect()")
(Pdb) 
=========================== short test summary info ============================
FAIL testing/python/collect.py::TestGenerator::test_generative_functions_unique_explicit_names
=================== 1 failed, 78 deselected in 0.34 seconds ====================

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: infrastructureimprovement to development/releases/CI structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions