From 37158f530367180edcd905da4a3f576b643cba23 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 14 Mar 2019 18:32:42 +0100 Subject: [PATCH 1/2] tests: fix test_pdb_interaction_continue_recursive with pdbpp --- testing/test_pdb.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 43d640614..0b92aa356 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -528,15 +528,13 @@ class TestPDB(object): import sys import types - newglobals = { - 'Pdb': self.__class__, # NOTE: different with pdb.Pdb - 'sys': sys, - } if sys.version_info < (3, ): do_debug_func = pdb.Pdb.do_debug.im_func else: do_debug_func = pdb.Pdb.do_debug + newglobals = do_debug_func.__globals__.copy() + newglobals['Pdb'] = self.__class__ orig_do_debug = types.FunctionType( do_debug_func.__code__, newglobals, do_debug_func.__name__, do_debug_func.__defaults__, From bdac9d3dd0fc21cbfe63108c3180f7f90b8aea08 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 14 Mar 2019 19:06:46 +0100 Subject: [PATCH 2/2] tests: improve test_pdb_interaction_doctest - ignore pdbrc (might be done in general, but this was the only affected test) - fail faster in case of unexpected failure --- testing/test_pdb.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 0b92aa356..68cb1cf00 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -457,7 +457,7 @@ class TestPDB(object): child.read() self.flush(child) - def test_pdb_interaction_doctest(self, testdir): + def test_pdb_interaction_doctest(self, testdir, monkeypatch): p1 = testdir.makepyfile( """ import pytest @@ -468,11 +468,18 @@ class TestPDB(object): ''' """ ) + # Prevent ~/.pdbrc etc to output anything. + monkeypatch.setenv("HOME", str(testdir)) + child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1) child.expect("Pdb") - child.sendline("i") - child.expect("0") + + assert "UNEXPECTED EXCEPTION: AssertionError()" in child.before.decode("utf8") + + child.sendline("'i=%i.' % i") child.expect("Pdb") + assert "\r\n'i=0.'\r\n" in child.before.decode("utf8") + child.sendeof() rest = child.read().decode("utf8") assert "1 failed" in rest