chiark / gitweb /
documentation/python: explicitly test builtin BaseException as well.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 26 Sep 2024 18:09:12 +0000 (20:09 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 28 Sep 2024 01:44:29 +0000 (03:44 +0200)
It contains members with unresolvable signatures. It's now tested through
a derived class in test_inspect.String, but once base class members get
omitted from the output, that gets lost.

documentation/test_python/inspect_builtin/inspect_builtin.BaseException-310.html [new file with mode: 0644]
documentation/test_python/inspect_builtin/inspect_builtin.BaseException.html [new file with mode: 0644]
documentation/test_python/inspect_builtin/inspect_builtin.html
documentation/test_python/inspect_builtin/inspect_builtin.py
documentation/test_python/inspect_builtin/inspect_builtin36.html
documentation/test_python/inspect_builtin/inspect_builtin39.html
documentation/test_python/inspect_string/inspect_string/__init__.py
documentation/test_python/test_inspect.py

diff --git a/documentation/test_python/inspect_builtin/inspect_builtin.BaseException-310.html b/documentation/test_python/inspect_builtin/inspect_builtin.BaseException-310.html
new file mode 100644 (file)
index 0000000..b14f251
--- /dev/null
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>inspect_builtin.BaseException | 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>
+          <span class="m-breadcrumb"><a href="inspect_builtin.html">inspect_builtin</a>.<wbr/></span>BaseException <span class="m-thin">class</span>
+        </h1>
+        <p>Common base class for all exceptions</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>
diff --git a/documentation/test_python/inspect_builtin/inspect_builtin.BaseException.html b/documentation/test_python/inspect_builtin/inspect_builtin.BaseException.html
new file mode 100644 (file)
index 0000000..0d6f274
--- /dev/null
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>inspect_builtin.BaseException | 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>
+          <span class="m-breadcrumb"><a href="inspect_builtin.html">inspect_builtin</a>.<wbr/></span>BaseException <span class="m-thin">class</span>
+        </h1>
+        <p>Common base class for all exceptions</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="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>
+            <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 74a2585ce5f31d78ec0c980cf1555e188693dfc7..feaad462251141e5f4ba06ddeb07276fd362bf21 100644 (file)
             <li>
               Reference
               <ul>
+                <li><a href="#classes">Classes</a></li>
                 <li><a href="#functions">Functions</a></li>
               </ul>
             </li>
           </ul>
         </nav>
+        <section id="classes">
+          <h2><a href="#classes">Classes</a></h2>
+          <dl class="m-doc">
+            <dt>class <a href="inspect_builtin.BaseException.html" class="m-doc">BaseException</a></dt>
+            <dd>Common base class for all exceptions</dd>
+          </dl>
+        </section>
         <section id="functions">
           <h2><a href="#functions">Functions</a></h2>
           <dl class="m-doc">
index 12a6d880d44c11b040a7507ff5187e4cdbe8189d..e7fe13e1764a95e88aa88be34500fa4524d42970 100644 (file)
@@ -1,7 +1,9 @@
 import sys
 from math import log, pow
 
-__all__ = ['pow', 'log']
+from builtins import BaseException
+
+__all__ = ['pow', 'log', 'BaseException']
 
 # Signature with / for pow() is not present in 3.6 so it makes no sense to have
 # it there.
index b9e7b300cc43433ce6940beee7a9d831f285f5e8..be0e6e4edce36558f558ce7781d0b7150016c131 100644 (file)
             <li>
               Reference
               <ul>
+                <li><a href="#classes">Classes</a></li>
                 <li><a href="#functions">Functions</a></li>
               </ul>
             </li>
           </ul>
         </nav>
+        <section id="classes">
+          <h2><a href="#classes">Classes</a></h2>
+          <dl class="m-doc">
+            <dt>class <a href="inspect_builtin.BaseException.html" class="m-doc">BaseException</a></dt>
+            <dd>Common base class for all exceptions</dd>
+          </dl>
+        </section>
         <section id="functions">
           <h2><a href="#functions">Functions</a></h2>
           <dl class="m-doc">
index 5711a4e96256b9d240c30e00fd8bc072cde95339..47aecf058fc7b58a53fdf6b92d8e322de6535c69 100644 (file)
             <li>
               Reference
               <ul>
+                <li><a href="#classes">Classes</a></li>
                 <li><a href="#functions">Functions</a></li>
               </ul>
             </li>
           </ul>
         </nav>
+        <section id="classes">
+          <h2><a href="#classes">Classes</a></h2>
+          <dl class="m-doc">
+            <dt>class <a href="inspect_builtin.BaseException.html" class="m-doc">BaseException</a></dt>
+            <dd>Common base class for all exceptions</dd>
+          </dl>
+        </section>
         <section id="functions">
           <h2><a href="#functions">Functions</a></h2>
           <dl class="m-doc">
index adb06cafa8ddd7f5f2f3622d7608efbc67bfd1d4..21ff7c003ca7fe897946a301d44d4410c51d776d 100644 (file)
@@ -93,8 +93,9 @@ class FooSlots:
 class DerivedException(BaseException):
     """A class deriving from BaseException, which has the weird args getset_descriptor"""
 
-    # Note: once we properly handle properties of base classes, we might want
-    # to import BaseException and add it to __all__ so it gets parsed directly
+    # TODO Once we properly handle properties of base classes, this should not
+    # list any of the base members anymore and should just act as a
+    # verification that indeed nothing leaks.
 
 class Specials:
     """Special class members"""
index fee28f5e42399724863693f4e2f44e349f016532..f7d7f505158fb957369a59a1b093829367876fae 100644 (file)
@@ -127,6 +127,13 @@ class Builtin(BaseInspectTestCase):
             file = 'inspect_builtin36.html'
         self.assertEqual(*self.actual_expected_contents('inspect_builtin.html', file))
 
+        # BaseException has the weird args getset_descriptor. Python 3.11 adds
+        # BaseException.add_note().
+        if sys.version_info >= (3, 11):
+            self.assertEqual(*self.actual_expected_contents('inspect_builtin.BaseException.html'))
+        else:
+            self.assertEqual(*self.actual_expected_contents('inspect_builtin.BaseException.html', 'inspect_builtin.BaseException-310.html'))
+
 class NameMapping(BaseInspectTestCase):
     def test(self):
         self.run_python({