10

I would like to use py.test combined with hunter:

PYTHONHUNTER="module_startswith='foo'" py.test -s -k test_bar

Unfortunately the output (trace) of hunter is not visible.

Version:

foo_cok_d@aptguettler:~$ py.test --version

This is pytest version 3.4.2, imported from /home/foo_cok_d/local/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
  pytest-xdist-1.22.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/xdist/looponfail.py
  pytest-xdist-1.22.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/xdist/plugin.py
  pytest-forked-0.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/pytest_forked/__init__.pyc

In a simpler (smaller) virtualenv it works (same pytest version, but no plugins).

What could be the reason?

How to debug this?

Max Voitko
  • 1,542
  • 1
  • 17
  • 32
guettli
  • 25,042
  • 81
  • 346
  • 663

2 Answers2

9

I found a work-around.

If I these two lines, then the -s option (shortcut for --capture=no) for py.test works.

    def test_when_the_moon_is_in_the_seventh_house(self):
+        import hunter
+        hunter.trace(module_startswith='modlink')
        ...

And I will see the race, and I am happy.

A solution without modifying the source code would be nice.

guettli
  • 25,042
  • 81
  • 346
  • 663
0
  1. Use respective pytest options for debugging:

    pytest -v --tb=long

  2. Run program in debug mode with breakpoints in your IDE.

Example: How to debug in PyCharm.

Max Voitko
  • 1,542
  • 1
  • 17
  • 32