diff options
author | Daniel Hahler <git@thequod.de> | 2019-03-15 00:52:12 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-03-15 00:52:12 +0100 |
commit | 7afe17740fedd423bdf22d01a45ca3bb16cbb295 (patch) | |
tree | c8cb26f99e5e9f5cfb390d1b2f03e4192baf777a /testing/test_pdb.py | |
parent | 437ff1c01a660b1106f5bd49160a4b4d30171093 (diff) | |
parent | 158432217c8ae7fdaf4e9c47156c72b8674d9fa5 (diff) | |
download | pytest-7afe17740fedd423bdf22d01a45ca3bb16cbb295.tar.gz |
Merge master into features
Diffstat (limited to 'testing/test_pdb.py')
-rw-r--r-- | testing/test_pdb.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/testing/test_pdb.py b/testing/test_pdb.py index f9a050b10..5b62def2d 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -459,7 +459,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 @@ -470,11 +470,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 @@ -530,15 +537,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__, |