You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python-zope-testrunner/SOURCES/172.patch

467 lines
19 KiB

From febaab0fbdf5d0a4bd16c27f5c5c641868b9c584 Mon Sep 17 00:00:00 2001
From: dieter <dieter.maurer@online.de>
Date: Sat, 1 Jun 2024 08:55:24 +0200
Subject: [PATCH] use more `...` in doctests to make them pass for Python 3.13
and earlier Python versions
---
.../testrunner/tests/testrunner-colors.rst | 8 ++---
.../testrunner/tests/testrunner-debugging.rst | 2 +-
.../tests/testrunner-edge-cases.rst | 29 +++++----------
.../testrunner/tests/testrunner-errors.rst | 36 +++++++++----------
.../testrunner/tests/testrunner-ex/gcset.py | 17 ++++++---
.../tests/testrunner-gc-after-test.rst | 8 ++---
src/zope/testrunner/tests/testrunner-gc.rst | 2 +-
.../tests/testrunner-layers-ntd.rst | 21 ++++-------
8 files changed, 56 insertions(+), 67 deletions(-)
diff --git a/src/zope/testrunner/tests/testrunner-colors.rst b/src/zope/testrunner/tests/testrunner-colors.rst
index ebf7fbf..be4b864 100644
--- a/src/zope/testrunner/tests/testrunner-colors.rst
+++ b/src/zope/testrunner/tests/testrunner-colors.rst
@@ -82,7 +82,7 @@ A failed test run highlights the failures in red:
Failed doctest test for sample2.sampletests_e.eek
File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
{normal}File "{boldblue}testrunner-ex/sample2/sampletests_e.py{normal}", line {boldred}30{normal}, in {boldcyan}sample2.sampletests_e.eek{normal}
Failed example:
{cyan} f(){normal}
@@ -120,7 +120,7 @@ A failed test run highlights the failures in red:
Failed doctest test for e.rst
File "testrunner-ex/sample2/e.rst", line 0
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
{normal}File "{boldblue}testrunner-ex/sample2/e.rst{normal}", line {boldred}4{normal}, in {boldcyan}e.rst{normal}
Failed example:
{cyan} f(){normal}
@@ -189,7 +189,7 @@ colors:
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
{normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
Failed example:
{cyan} print_pledge(){normal}
@@ -223,7 +223,7 @@ apart:
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
{normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
Failed example:
{cyan} print_pledge(){normal}
diff --git a/src/zope/testrunner/tests/testrunner-debugging.rst b/src/zope/testrunner/tests/testrunner-debugging.rst
index 6f7f0c8..7c74316 100644
--- a/src/zope/testrunner/tests/testrunner-debugging.rst
+++ b/src/zope/testrunner/tests/testrunner-debugging.rst
@@ -36,7 +36,7 @@ runner will enter pdb at that point:
Running zope.testrunner.layer.UnitTests tests:
...
> testrunner-ex/sample3/sampletests_d.py(27)test_set_trace1()
- -> y = x # noqa: F841
+ -> ...
(Pdb) p x
1
(Pdb) c
diff --git a/src/zope/testrunner/tests/testrunner-edge-cases.rst b/src/zope/testrunner/tests/testrunner-edge-cases.rst
index 006ef82..c50ee8b 100644
--- a/src/zope/testrunner/tests/testrunner-edge-cases.rst
+++ b/src/zope/testrunner/tests/testrunner-edge-cases.rst
@@ -93,7 +93,7 @@ Using pdb.set_trace in a function called by an ordinary test:
... # doctest: +ELLIPSIS
Running zope.testrunner.layer.UnitTests tests:...
> testrunner-ex/sample3/sampletests_d.py(47)f()
- -> y = x # noqa: F841
+ -> ...
(Pdb) p x
1
(Pdb) c
@@ -111,11 +111,9 @@ Using pdb.set_trace in a function called by a doctest in a doc string:
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
> testrunner-ex/sample3/sampletests_d.py(NNN)f()
- -> y = x # noqa: F841
+ -> ...
(Pdb) n
- --Return--
- > ...->None
- -> y = x # noqa: F841
+ ...
(Pdb) p x
1
(Pdb) c
@@ -133,12 +131,9 @@ Using pdb in a docstring-based doctest
... finally: sys.stdin = real_stdin
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
- > <doctest sample3.sampletests_d.set_trace3[1]>(3)?()
- -> y = x
+ ...
(Pdb) n
- --Return--
- > ...->None
- -> y = x
+ ...
(Pdb) p x
1
(Pdb) c
@@ -157,12 +152,9 @@ Using pdb.set_trace in a doc file:
... finally: sys.stdin = real_stdin
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
- > <doctest set_trace5.rst[1]>(3)?()
- -> y = x
+ ...
(Pdb) n
- --Return--
- > ...->None
- -> y = x
+ ...
(Pdb) p x
1
(Pdb) c
@@ -181,12 +173,9 @@ Using pdb.set_trace in a function called by a doctest in a doc file:
... finally: sys.stdin = real_stdin
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
- > testrunner-ex/sample3/sampletests_d.py(NNN)f()
- -> y = x # noqa: F841
+ ...
(Pdb) n
- --Return--
- > ...->None
- -> y = x # noqa: F841
+ ...
(Pdb) p x
1
(Pdb) c
diff --git a/src/zope/testrunner/tests/testrunner-errors.rst b/src/zope/testrunner/tests/testrunner-errors.rst
index 092d187..65fafb0 100644
--- a/src/zope/testrunner/tests/testrunner-errors.rst
+++ b/src/zope/testrunner/tests/testrunner-errors.rst
@@ -34,7 +34,7 @@ be read only):
Failed doctest test for sample2.sampletests_e.eek
File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_e.py", line 30, in sample2.sampletests_e.eek
Failed example:
f()
@@ -70,7 +70,7 @@ be read only):
Failed doctest test for e.rst
File "testrunner-ex/sample2/e.rst", line 0
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/e.rst", line 4, in e.rst
Failed example:
f()
@@ -119,7 +119,7 @@ there'll be a summary of the errors at the end of the test:
Failed doctest test for sample2.sampletests_e.eek
File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_e.py", line 30,
in sample2.sampletests_e.eek
Failed example:
@@ -157,7 +157,7 @@ there'll be a summary of the errors at the end of the test:
Failed doctest test for e.rst
File "testrunner-ex/sample2/e.rst", line 0
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/e.rst", line 4, in e.rst
Failed example:
f()
@@ -210,7 +210,7 @@ Similarly for progress output, the progress ticker will be interrupted:
Failed doctest test for sample2.sampletests_e.eek
File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_e.py", line 30, in sample2.sampletests_e.eek
Failed example:
f()
@@ -254,7 +254,7 @@ Similarly for progress output, the progress ticker will be interrupted:
Failed doctest test for e.rst
File "testrunner-ex/sample2/e.rst", line 0
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/e.rst", line 4, in e.rst
Failed example:
f()
@@ -467,7 +467,7 @@ examples in the same test to fail. Each failure is reported:
Failed doctest test for sample2.sampletests_1.eek
File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 19,
in sample2.sampletests_1.eek
Failed example:
@@ -479,7 +479,7 @@ examples in the same test to fail. Each failure is reported:
File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
x = y
NameError: name 'y' is not defined
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 21,
in sample2.sampletests_1.eek
Failed example:
@@ -491,7 +491,7 @@ examples in the same test to fail. Each failure is reported:
File "<doctest sample2.sampletests_1.eek[1]>", line 1, in ?
x
NameError: name 'x' is not defined
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 24,
in sample2.sampletests_1.eek
Failed example:
@@ -524,7 +524,7 @@ me the first failed example in a doctest" :)
Failed doctest test for sample2.sampletests_1.eek
File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 19,
in sample2.sampletests_1.eek
Failed example:
@@ -557,7 +557,7 @@ The --hide-secondary-failures option is an alias for -1:
Failed doctest test for sample2.sampletests_1.eek
File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 19, in sample2.sampletests_1.eek
Failed example:
x = y
@@ -592,7 +592,7 @@ command-line options in sys.argv.
Failed doctest test for sample2.sampletests_1.eek
File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 19, in sample2.sampletests_1.eek
Failed example:
x = y
@@ -603,7 +603,7 @@ command-line options in sys.argv.
File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
x = y
NameError: name 'y' is not defined
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 21, in sample2.sampletests_1.eek
Failed example:
x
@@ -614,7 +614,7 @@ command-line options in sys.argv.
File "<doctest sample2.sampletests_1.eek[1]>", line 1, in ?
x
NameError: name 'x' is not defined
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/sample2/sampletests_1.py", line 24, in sample2.sampletests_1.eek
Failed example:
z = x + 1
@@ -650,7 +650,7 @@ kinds.
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
print_pledge()
@@ -692,7 +692,7 @@ caret marking the mismatching column positions.
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
print_pledge()
@@ -721,7 +721,7 @@ The -udiff option requests a standard "unified" diff:
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
print_pledge()
@@ -748,7 +748,7 @@ The -cdiff option requests a standard "context" diff:
Failed doctest test for pledge.pledge
File "testrunner-ex/pledge.py", line 24, in pledge
<BLANKLINE>
- ----------------------------------------------------------------------
+ ...
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
print_pledge()
diff --git a/src/zope/testrunner/tests/testrunner-ex/gcset.py b/src/zope/testrunner/tests/testrunner-ex/gcset.py
index ca0b71d..8c1801e 100644
--- a/src/zope/testrunner/tests/testrunner-ex/gcset.py
+++ b/src/zope/testrunner/tests/testrunner-ex/gcset.py
@@ -12,14 +12,21 @@
#
##############################################################################
import doctest
+import sys
+
+
+PY313 = sys.version_info[:2] >= (3, 13)
def make_sure_gc_threshold_is_701_11_9():
- """
- >>> import gc
- >>> gc.get_threshold()
- (701, 11, 9)
- """
+ pass
+
+
+make_sure_gc_threshold_is_701_11_9.__doc__ = """\
+>>> import gc
+>>> gc.get_threshold()
+(701, 11, %d)
+""" % (0 if PY313 else 9)
def test_suite():
diff --git a/src/zope/testrunner/tests/testrunner-gc-after-test.rst b/src/zope/testrunner/tests/testrunner-gc-after-test.rst
index d21d571..15a0529 100644
--- a/src/zope/testrunner/tests/testrunner-gc-after-test.rst
+++ b/src/zope/testrunner/tests/testrunner-gc-after-test.rst
@@ -85,6 +85,10 @@ therefore does not show the warnings (even though two are issued).
test_failure (gc-after-test.GcAfterTestTests...)
Verbosity level 4 (or higher)
+ Note: starting with Python 3.13, the garbage collector identifies
+ an instance and its ``__dict__``; as a consequence, cycles
+ appear smaller than in preceding versions (not
+ mentioning the involved ``__dict__``s).
>>> sys.argv = 'test --gc-after-test -vvvv'.split()
>>> _ = testrunner.run_internal(defaults)
Running tests at level 1
@@ -95,13 +99,11 @@ therefore does not show the warnings (even though two are issued).
The following test left cyclic garbage behind:
test_cycle_with_resource (gc-after-test.GcAfterTestTests...)
Cycle 1
- * ...
* ...
test_cycle_without_resource (gc-after-test.GcAfterTestTests...) (N.NNN s) [2]
The following test left cyclic garbage behind:
test_cycle_without_resource (gc-after-test.GcAfterTestTests...)
Cycle 1
- * ...
* ...
test_exception (gc-after-test.GcAfterTestTests...) (N.NNN s)
<BLANKLINE>
@@ -122,13 +124,11 @@ therefore does not show the warnings (even though two are issued).
The following test left cyclic garbage behind:
test_test_holds_cycle (gc-after-test.GcAfterTestTests...)
Cycle 1
- * ...
* ...
test_traceback_cycle (gc-after-test.GcAfterTestTests...) (N.NNN s) [5]
The following test left cyclic garbage behind:
test_traceback_cycle (gc-after-test.GcAfterTestTests...)
Cycle 1
- * ...
* ...
Ran 7 tests with 1 failures, 1 errors and 0 skipped in N.NNN seconds.
Tearing down left over layers:
diff --git a/src/zope/testrunner/tests/testrunner-gc.rst b/src/zope/testrunner/tests/testrunner-gc.rst
index bea3305..be061d7 100644
--- a/src/zope/testrunner/tests/testrunner-gc.rst
+++ b/src/zope/testrunner/tests/testrunner-gc.rst
@@ -112,4 +112,4 @@ The output statistics are written to standard error.
>>> sys.stderr = stderr
>>> print(err.getvalue()) # doctest: +ELLIPSIS
- gc: collecting generation ...
+ gc: collect...
diff --git a/src/zope/testrunner/tests/testrunner-layers-ntd.rst b/src/zope/testrunner/tests/testrunner-layers-ntd.rst
index 7e65d09..d990351 100644
--- a/src/zope/testrunner/tests/testrunner-layers-ntd.rst
+++ b/src/zope/testrunner/tests/testrunner-layers-ntd.rst
@@ -167,8 +167,7 @@ that is run as a subprocess:
Tear down sample1.sampletests_ntds.Layer ... not supported
Running in a subprocess.
Set up sample2.sampletests_ntds.Layer in 0.000 seconds.
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(37)test_something()->None
+ ...> testrunner-ex/sample2/sampletests_ntds.py(37)test_something()->None
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -176,8 +175,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(40)test_something2()->None
+ ...> testrunner-ex/sample2/sampletests_ntds.py(40)test_something2()->None
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -185,8 +183,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(43)test_something3()->None
+ ...> testrunner-ex/sample2/sampletests_ntds.py(43)test_something3()->None
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -194,8 +191,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(46)test_something4()->None
+ ...> testrunner-ex/sample2/sampletests_ntds.py(46)test_something4()->None
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -203,8 +199,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(52)f()->None
+ ...> testrunner-ex/sample2/sampletests_ntds.py(52)f()->None
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -212,8 +207,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > <doctest sample2.sampletests_ntds.test_set_trace[0]>(3)?()
+ ...> <doctest sample2.sampletests_ntds.test_set_trace[0]>(3)?()
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>
@@ -221,8 +215,7 @@ that is run as a subprocess:
Can't use pdb.set_trace when running a layer as a subprocess!
**********************************************************************
<BLANKLINE>
- --Return--
- > testrunner-ex/sample2/sampletests_ntds.py(NNN)f()
+ ...> testrunner-ex/sample2/sampletests_ntds.py(NNN)f()
-> import pdb; pdb.set_trace()
(Pdb) c
<BLANKLINE>