chiark / gitweb /
documentation/python. adapt inspect tests to Python 3.11 / 3.12 changes.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 22:31:28 +0000 (00:31 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 23:48:41 +0000 (01:48 +0200)
documentation/test_python/inspect_annotations/math.html
documentation/test_python/inspect_annotations/math39.html [new file with mode: 0644]
documentation/test_python/inspect_string/inspect_string.DerivedException-310.html [new file with mode: 0644]
documentation/test_python/inspect_string/inspect_string.DerivedException.html
documentation/test_python/test_inspect.py

index cb97c7fafec37b622d61ef025569f39ea9b45d45..982c3150a0c4f6df410b641893ecd3884d20a397 100644 (file)
@@ -57,7 +57,7 @@ Return the logarithm of x to the given base.</dd>
             </h3>
             <p>log(x, [base=math.e])
 Return the logarithm of x to the given base.</p>
-<p>If the base not specified, returns the natural logarithm (base e) of x.</p>
+<p>If the base is not specified, returns the natural logarithm (base e) of x.</p>
           </div></section>
         </section>
       </div>
diff --git a/documentation/test_python/inspect_annotations/math39.html b/documentation/test_python/inspect_annotations/math39.html
new file mode 100644 (file)
index 0000000..cb97c7f
--- /dev/null
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>math | My Python Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Python Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          math <span class="m-thin">module</span>
+        </h1>
+        <p>This module provides access to the mathematical functions
+defined by the C standard.</p>
+        <nav class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#functions">Functions</a></li>
+              </ul>
+            </li>
+          </ul>
+        </nav>
+        <section id="functions">
+          <h2><a href="#functions">Functions</a></h2>
+          <dl class="m-doc">
+            <dt id="pow">
+              <span class="m-doc-wrap-bumper">def <a href="#pow" class="m-doc-self">pow</a>(</span><span class="m-doc-wrap">x, y<span class="m-text m-dim">, /</span>)</span>
+            </dt>
+            <dd>Return x**y (x to the power of y).</dd>
+            <dt>
+              <span class="m-doc-wrap-bumper">def <a href="#log" class="m-doc">log</a>(</span><span class="m-doc-wrap">...)</span>
+            </dt>
+            <dd>log(x, [base=math.e])
+Return the logarithm of x to the given base.</dd>
+          </dl>
+        </section>
+        <section>
+          <h2>Function documentation</h2>
+          <section class="m-doc-details" id="log"><div>
+            <h3>
+              <span class="m-doc-wrap-bumper">def math.<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#log" class="m-doc-self">log</a>(</span><span class="m-doc-wrap">...)</span></span>
+            </h3>
+            <p>log(x, [base=math.e])
+Return the logarithm of x to the given base.</p>
+<p>If the base not specified, returns the natural logarithm (base e) of x.</p>
+          </div></section>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
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 (file)
index 0000000..28d58e3
--- /dev/null
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>inspect_string.DerivedException | My Python Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Python Project</a>
+      <div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
+        <a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
+        <a id="m-navbar-hide" href="#" title="Hide navigation"></a>
+      </div>
+      <div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
+        <div class="m-row">
+          <ol class="m-col-t-12 m-col-m-none">
+            <li><a href="modules.html">Modules</a></li>
+            <li><a href="classes.html">Classes</a></li>
+          </ol>
+        </div>
+      </div>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          <span class="m-breadcrumb"><a href="inspect_string.html">inspect_string</a>.<wbr/></span>DerivedException <span class="m-thin">class</span>
+        </h1>
+        <p>A class deriving from BaseException, which has the weird args getset_descriptor</p>
+        <nav class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#methods">Methods</a></li>
+                <li><a href="#dunder-methods">Special methods</a></li>
+                <li><a href="#properties">Properties</a></li>
+              </ul>
+            </li>
+          </ul>
+        </nav>
+        <section id="methods">
+          <h2><a href="#methods">Methods</a></h2>
+          <dl class="m-doc">
+            <dt id="with_traceback">
+              <span class="m-doc-wrap-bumper">def <a href="#with_traceback" class="m-doc-self">with_traceback</a>(</span><span class="m-doc-wrap">...)</span>
+            </dt>
+            <dd>Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.</dd>
+          </dl>
+        </section>
+        <section id="dunder-methods">
+          <h2><a href="#dunder-methods">Special methods</a></h2>
+          <dl class="m-doc">
+            <dt id="__reduce__">
+              <span class="m-doc-wrap-bumper">def <a href="#__reduce__" class="m-doc-self">__reduce__</a>(</span><span class="m-doc-wrap">...)</span>
+            </dt>
+            <dd></dd>
+            <dt id="__setstate__">
+              <span class="m-doc-wrap-bumper">def <a href="#__setstate__" class="m-doc-self">__setstate__</a>(</span><span class="m-doc-wrap">...)</span>
+            </dt>
+            <dd></dd>
+          </dl>
+        </section>
+        <section id="properties">
+          <h2><a href="#properties">Properties</a></h2>
+          <dl class="m-doc">
+            <dt id="__cause__">
+              <a href="#__cause__" class="m-doc-self">__cause__</a> <span class="m-label m-flat m-warning">get</span>
+            </dt>
+            <dd>exception cause</dd>
+            <dt id="__context__">
+              <a href="#__context__" class="m-doc-self">__context__</a> <span class="m-label m-flat m-warning">get</span>
+            </dt>
+            <dd>exception context</dd>
+            <dt id="args">
+              <a href="#args" class="m-doc-self">args</a> <span class="m-label m-flat m-warning">get</span>
+            </dt>
+            <dd></dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 28d58e3be6fd46eba1051d7048991386a60e4e3c..8a1578d509bb5f491981ea71e482fcae63b7a039 100644 (file)
         <section id="methods">
           <h2><a href="#methods">Methods</a></h2>
           <dl class="m-doc">
+            <dt id="add_note">
+              <span class="m-doc-wrap-bumper">def <a href="#add_note" class="m-doc-self">add_note</a>(</span><span class="m-doc-wrap">...)</span>
+            </dt>
+            <dd>Exception.add_note(note) --
+add a note to the exception</dd>
             <dt id="with_traceback">
               <span class="m-doc-wrap-bumper">def <a href="#with_traceback" class="m-doc-self">with_traceback</a>(</span><span class="m-doc-wrap">...)</span>
             </dt>
index bc663b0ac3e2196778dcb066b67a22afdffc0491..77060898c5df568535002a45818a269d19d401fe 100644 (file)
@@ -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):