[Pytest-commit] commit/pytest: hpk42: make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Sep 6 15:29:08 CEST 2013
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/commits/8ccfe395100d/
Changeset: 8ccfe395100d
User: hpk42
Date: 2013-09-06 15:29:00
Summary: make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed
anymore), turning ``pytest.set_trace()`` into a mere shortcut.
Affected #: 3 files
diff -r 2596c935866532b97023e739dd978dc15796743c -r 8ccfe395100dfe6be00805a25b2516aec702949a CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
Changes between 2.3.5 and 2.4.DEV
-----------------------------------
+- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed
+ anymore), making ``pytest.set_trace()`` a mere shortcut.
+
- fix issue181: --pdb now also works on collect errors (and
on internal errors) . This was implemented by a slight internal
refactoring and the introduction of a new hook
diff -r 2596c935866532b97023e739dd978dc15796743c -r 8ccfe395100dfe6be00805a25b2516aec702949a _pytest/pdb.py
--- a/_pytest/pdb.py
+++ b/_pytest/pdb.py
@@ -16,6 +16,12 @@
if config.getvalue("usepdb"):
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
+ old_trace = py.std.pdb.set_trace
+ def fin():
+ py.std.pdb.set_trace = old_trace
+ py.std.pdb.set_trace = pytest.set_trace
+ config._cleanup.append(fin)
+
class pytestPDB:
""" Pseudo PDB that defers to the real pdb. """
item = None
diff -r 2596c935866532b97023e739dd978dc15796743c -r 8ccfe395100dfe6be00805a25b2516aec702949a testing/test_pdb.py
--- a/testing/test_pdb.py
+++ b/testing/test_pdb.py
@@ -134,6 +134,22 @@
if child.isalive():
child.wait()
+ def test_pdb_set_trace_interception(self, testdir):
+ p1 = testdir.makepyfile("""
+ import pdb
+ def test_1():
+ pdb.set_trace()
+ """)
+ child = testdir.spawn_pytest(str(p1))
+ child.expect("test_1")
+ child.expect("(Pdb)")
+ child.sendeof()
+ rest = child.read()
+ assert "1 failed" in rest
+ assert "reading from stdin while output" not in rest
+ if child.isalive():
+ child.wait()
+
def test_pdb_and_capsys(self, testdir):
p1 = testdir.makepyfile("""
import pytest
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list