Repository navigation
Failures in test_doctest (due to nonempty .pdbrc) #120109
Copy link
Copy link
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
I rarely run whole test suite locally, so I'm not sure when it was broken. IIRC, after merging new repl.
BTW, setting PYTHON_BASIC_REPL doesn't help.
$ cat ~/.pdbrc
alias si from cmath import sin;; sin(%1)
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
$ ./configure -q && make -s
[just stuff from 108562]
$ ./python -m test test_doctest -v
[...]
======================================================================
FAIL: test_debug (test.test_doctest.test_doctest)
Doctest: test.test_doctest.test_doctest.test_debug
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sk/src/cpython/Lib/doctest.py", line 2327, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_doctest.test_doctest.test_debug
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 1992, in test_debug
----------------------------------------------------------------------
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2010, in test.test_doctest.test_doctest.test_debug
Failed example:
try: doctest.debug_src(s)
finally: sys.stdin = real_stdin
Expected:
> <string>(1)<module>()
(Pdb) next
12
--Return--
> <string>(1)<module>()->None
(Pdb) print(x)
12
(Pdb) continue
Got:
(Pdb) next
12
--Return--
> <string>(1)<module>()->None
(Pdb) print(x)
12
(Pdb) continue
======================================================================
FAIL: test_pdb_set_trace (test.test_doctest.test_doctest)
Doctest: test.test_doctest.test_doctest.test_pdb_set_trace
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sk/src/cpython/Lib/doctest.py", line 2327, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_doctest.test_doctest.test_pdb_set_trace
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2024, in test_pdb_set_trace
----------------------------------------------------------------------
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2057, in test.test_doctest.test_doctest.test_pdb_set_trace
Failed example:
try: runner.run(test)
finally: sys.stdin = real_stdin
Expected:
> <doctest foo-bar@baz[2]>(1)<module>()
-> import pdb; pdb.set_trace()
(Pdb) print(x)
42
(Pdb) continue
TestResults(failed=0, attempted=3)
Got:
(Pdb) print(x)
42
(Pdb) continue
TestResults(failed=0, attempted=3)
----------------------------------------------------------------------
ile "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2085, in test.test_doctest.test_doctest.test_pdb_set_trace
Failed example:
try:
runner.run(test)
finally:
sys.stdin = real_stdin
Expected:
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace[9]>(3)calls_set_trace()
-> import pdb; pdb.set_trace()
(Pdb) print(y)
2
(Pdb) up
> <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
(Pdb) print(x)
1
(Pdb) continue
TestResults(failed=0, attempted=2)
Got:
(Pdb) print(y)
2
(Pdb) up
> <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
(Pdb) print(x)
1
(Pdb) continue
TestResults(failed=0, attempted=2)
----------------------------------------------------------------------
----------------------------------------------------------------------
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2123, in test.test_doctest.test_doctest.test_pdb_set_trace
Failed example:
try: runner.run(test)
finally: sys.stdin = real_stdin
# doctest: +NORMALIZE_WHITESPACE
Expected:
> <doctest foo-bar@baz[1]>(3)g()
-> import pdb; pdb.set_trace()
(Pdb) step
--Return--
> <doctest foo-bar@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) next
--Return--
> <doctest foo-bar@baz[0]>(2)f()->None
-> g(x*2)
(Pdb) list
1 def f(x):
2 -> g(x*2)
[EOF]
(Pdb) next
--Return--
> <doctest foo-bar@baz[2]>(1)<module>()->None
-> f(3)
(Pdb) list
1 -> f(3)
[EOF]
(Pdb) continue
**********************************************************************
File "foo-bar@baz.py", line 7, in foo-bar@baz
Failed example:
f(3)
Expected nothing
Got:
9
TestResults(failed=1, attempted=3)
Got:
(Pdb) step
--Return--
> <doctest foo-bar@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) next
--Return--
> <doctest foo-bar@baz[0]>(2)f()->None
-> g(x*2)
(Pdb) list
1 def f(x):
2 -> g(x*2)
[EOF]
(Pdb) next
--Return--
> <doctest foo-bar@baz[2]>(1)<module>()->None
-> f(3)
(Pdb) list
1 -> f(3)
[EOF]
(Pdb) continue
**********************************************************************
File "foo-bar@baz.py", line 7, in foo-bar@baz
Failed example:
f(3)
Expected nothing
Got:
9
TestResults(failed=1, attempted=3)
======================================================================
FAIL: test_pdb_set_trace_nested (test.test_doctest.test_doctest)
Doctest: test.test_doctest.test_doctest.test_pdb_set_trace_nested
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sk/src/cpython/Lib/doctest.py", line 2327, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_doctest.test_doctest.test_pdb_set_trace_nested
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2165, in test_pdb_set_trace_nested
----------------------------------------------------------------------
File "/home/sk/src/cpython/Lib/test/test_doctest/test_doctest.py", line 2202, in test.test_doctest.test_doctest.test_pdb_set_trace_neste
d
Failed example:
try:
runner.run(test)
finally:
sys.stdin = real_stdin
# doctest: +REPORT_NDIFF
Differences (ndiff with -expected +actual):
- > <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(4)calls_set_trace()
- -> import pdb; pdb.set_trace()
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1()
(Pdb) print(y)
1
(Pdb) step
--Call--
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(7)f1()
-> def f1(self):
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(8)f1()
-> x = 1
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(9)f1()
-> self.f2()
(Pdb) step
--Call--
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(11)f2()
-> def f2(self):
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(12)f2()
-> z = 1
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(13)f2()
-> z = 2
(Pdb) print(z)
1
(Pdb) up
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(9)f1()
-> self.f2()
(Pdb) print(x)
1
(Pdb) up
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1()
(Pdb) print(y)
1
(Pdb) up
> <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
(Pdb) print(foo)
*** NameError: name 'foo' is not defined
(Pdb) continue
TestResults(failed=0, attempted=2)
----------------------------------------------------------------------
Ran 69 tests in 4.415s
FAILED (failures=3)
test test_doctest failed
test_doctest failed (3 failures)
== Tests result: FAILURE ==
1 test failed:
test_doctest
Total duration: 5.4 sec
Total tests: run=69 failures=3
Total test files: run=1/1 failed=1
Result: FAILURE
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
picnixz commentedon Jun 5, 2024
It appears that the first lines until the first actual usage of pdb are never printed. Have you perhaps changed some lines / used an incorrect branch / not up-to-date branch?
EDIT: I cannot reproduce by the way (forgot to mention it). I'm on OpenSUSE 15.5.
sobolevn commentedon Jun 5, 2024
I cannot reproduce it on macos
skirpichev commentedon Jun 5, 2024
Well, first that happened not on the master^Wmain. But I did update (you can see my fork) and I run
git clean -Xdf.picnixz commentedon Jun 5, 2024
Err... maybe it's a coincidence, but is your branch with those issues the #108562, namely the PR #116346? (you mentioned 108562 so I think it's the corresponding issue?). If so, I don't think it's up-to-date. If not, which branch are you working on?
skirpichev commentedon Jun 6, 2024
These warnings exist on in the main.
The main.
Ok, as I expected, this happens due to local configuration:
I'll update description.
Can you reproduce issue with:
?
[-]Failures in test_doctest[/-][+]Failures in test_doctest (due to nonempty .pdbrc)[/+]skirpichev commentedon Jun 6, 2024
9c93350 - no errors; I'll try to bisect.
skirpichev commentedon Jun 6, 2024
Bisected to 44f9a84
CC @gaogaotiantian
gaogaotiantian commentedon Jun 6, 2024
This is a known issue #119824 and the fix is in #119882. It's still under review and will be backported.
skirpichev commentedon Jun 6, 2024
Ok, sorry for a duplicate.
picnixz commentedon Jun 6, 2024
Oh, I actually dismissed this one because I thought that .pdbrc would not have been read at all because of
readrc=Falsebut it appears not.gaogaotiantian commentedon Jun 6, 2024
There's no need to be sorry :) You did a great job linking the issue together so we can solve them both when the PR is merged.
gaogaotiantian commentedon Jun 6, 2024
.pdbrcshould not be read whenreadrc=False. Where was it set toFalse?pdb.set_trace()will not setreadrctoFalse.picnixz commentedon Jun 6, 2024
Ah my bad! I actually looked at the incorrect doctest file. Actually in
test_pdb, there are somereadrc=Falsecalls (which I thought were the culprits) but not in thetest_doctestfile! So, maybe just adding thosereadrc=Falsefor the tests intest_doctestwould be fine?skirpichev commentedon Jun 6, 2024
Hmm, maybe it's a good idea to permit readrc argument here and use that in test_doctest/* to isolate from local environment?
gaogaotiantian commentedon Jun 6, 2024
readrcis only available to thepdb.Pdbclass now.pdb.set_trace()can't do that. We can propose something but that would be a new feature to pdb.skirpichev commentedon Jun 25, 2024
#119882 was merged and it seems this is fixed.