From: Vladimír Vondruš Date: Sat, 14 Sep 2024 22:31:28 +0000 (+0200) Subject: documentation/python. adapt inspect tests to Python 3.11 / 3.12 changes. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=54fccfb5388370b1a8417670f1e9bf9610bb4814;p=blog.git documentation/python. adapt inspect tests to Python 3.11 / 3.12 changes. --- diff --git a/documentation/test_python/inspect_annotations/math.html b/documentation/test_python/inspect_annotations/math.html index cb97c7fa..982c3150 100644 --- a/documentation/test_python/inspect_annotations/math.html +++ b/documentation/test_python/inspect_annotations/math.html @@ -57,7 +57,7 @@ Return the logarithm of x to the given base.

log(x, [base=math.e]) Return the logarithm of x to the given base.

-

If the base not specified, returns the natural logarithm (base e) of x.

+

If the base is not specified, returns the natural logarithm (base e) of x.

diff --git a/documentation/test_python/inspect_annotations/math39.html b/documentation/test_python/inspect_annotations/math39.html new file mode 100644 index 00000000..cb97c7fa --- /dev/null +++ b/documentation/test_python/inspect_annotations/math39.html @@ -0,0 +1,68 @@ + + + + + math | My Python Project + + + + + +
+
+
+
+
+

+ math module +

+

This module provides access to the mathematical functions +defined by the C standard.

+ +
+

Functions

+
+
+ def pow(x, y, /) +
+
Return x**y (x to the power of y).
+
+ def log(...) +
+
log(x, [base=math.e]) +Return the logarithm of x to the given base.
+
+
+
+

Function documentation

+
+

+ def math.log(...) +

+

log(x, [base=math.e]) +Return the logarithm of x to the given base.

+

If the base not specified, returns the natural logarithm (base e) of x.

+
+
+
+
+
+
+ + diff --git a/documentation/test_python/inspect_string/inspect_string.DerivedException-310.html b/documentation/test_python/inspect_string/inspect_string.DerivedException-310.html new file mode 100644 index 00000000..28d58e3b --- /dev/null +++ b/documentation/test_python/inspect_string/inspect_string.DerivedException-310.html @@ -0,0 +1,96 @@ + + + + + inspect_string.DerivedException | My Python Project + + + + + +
+
+
+
+
+

+ inspect_string.DerivedException class +

+

A class deriving from BaseException, which has the weird args getset_descriptor

+ +
+

Methods

+
+
+ def with_traceback(...) +
+
Exception.with_traceback(tb) -- +set self.__traceback__ to tb and return self.
+
+
+
+

Special methods

+
+
+ def __reduce__(...) +
+
+
+ def __setstate__(...) +
+
+
+
+
+

Properties

+
+
+ __cause__ get +
+
exception cause
+
+ __context__ get +
+
exception context
+
+ args get +
+
+
+
+
+
+
+
+ + diff --git a/documentation/test_python/inspect_string/inspect_string.DerivedException.html b/documentation/test_python/inspect_string/inspect_string.DerivedException.html index 28d58e3b..8a1578d5 100644 --- a/documentation/test_python/inspect_string/inspect_string.DerivedException.html +++ b/documentation/test_python/inspect_string/inspect_string.DerivedException.html @@ -51,6 +51,11 @@

Methods

+
+ def add_note(...) +
+
Exception.add_note(note) -- +add a note to the exception
def with_traceback(...)
diff --git a/documentation/test_python/test_inspect.py b/documentation/test_python/test_inspect.py index bc663b0a..77060898 100644 --- a/documentation/test_python/test_inspect.py +++ b/documentation/test_python/test_inspect.py @@ -46,9 +46,14 @@ class String(BaseInspectTestCase): self.assertEqual(*self.actual_expected_contents('inspect_string.another_module.html')) self.assertEqual(*self.actual_expected_contents('inspect_string.Foo.html')) self.assertEqual(*self.actual_expected_contents('inspect_string.FooSlots.html')) - self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html')) self.assertEqual(*self.actual_expected_contents('inspect_string.Specials.html')) + # Python 3.11 adds BaseException.add_note() + if sys.version_info >= (3, 11): + self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html')) + else: + self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html', 'inspect_string.DerivedException-310.html')) + self.assertEqual(*self.actual_expected_contents('classes.html')) self.assertEqual(*self.actual_expected_contents('modules.html')) @@ -70,7 +75,13 @@ class Object(BaseInspectTestCase): self.assertEqual(*self.actual_expected_contents('inspect_string.another_module.html', '../inspect_string/inspect_string.another_module.html')) self.assertEqual(*self.actual_expected_contents('inspect_string.Foo.html', '../inspect_string/inspect_string.Foo.html')) self.assertEqual(*self.actual_expected_contents('inspect_string.FooSlots.html', '../inspect_string/inspect_string.FooSlots.html')) - self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html', '../inspect_string/inspect_string.DerivedException.html')) + + # Python 3.11 adds BaseException.add_note() + if sys.version_info >= (3, 11): + self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html', '../inspect_string/inspect_string.DerivedException.html')) + else: + self.assertEqual(*self.actual_expected_contents('inspect_string.DerivedException.html', '../inspect_string/inspect_string.DerivedException-310.html')) + self.assertEqual(*self.actual_expected_contents('inspect_string.Specials.html', '../inspect_string/inspect_string.Specials.html')) self.assertEqual(*self.actual_expected_contents('classes.html', '../inspect_string/classes.html')) @@ -112,8 +123,14 @@ class Annotations(BaseInspectTestCase): 'INPUT_MODULES': [math] }) - if sys.version_info >= (3, 7, 4): + # 3.12 improves a docstring further. It got seemingly backported to + # 3.11.3 and 3.10.11 as well, but an actual build of 3.11.9 doesn't + # seem to have that, so checking this just on 3.12. + # https://github.com/python/cpython/pull/102049 + if sys.version_info >= (3, 12): file = 'math.html' + elif sys.version_info >= (3, 7, 4): + file = 'math39.html' # 3.7.3 and below has a different docstring # https://github.com/python/cpython/pull/13394 elif sys.version_info >= (3, 7):