chiark / gitweb /
documentation/python: yup, yet another variant of builtin math docstrings.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 23 Aug 2019 12:51:27 +0000 (14:51 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 25 Aug 2019 10:47:45 +0000 (12:47 +0200)
documentation/test_python/inspect_annotations/math.html
documentation/test_python/inspect_annotations/math373.html [new file with mode: 0644]
documentation/test_python/test_inspect.py

index ebfe209dd556e7e39d26bc6b877b209e4d74d81b..222af053d21125cac206eee1c7024a5f78e94112 100644 (file)
@@ -22,8 +22,8 @@
         <h1>
           math <span class="m-thin">module</span>
         </h1>
-        <p>This module is always available.  It provides access to the
-mathematical functions defined by the C standard.</p>
+        <p>This module provides access to the mathematical functions
+defined by the C standard.</p>
         <div class="m-block m-default">
           <h3>Contents</h3>
           <ul>
diff --git a/documentation/test_python/inspect_annotations/math373.html b/documentation/test_python/inspect_annotations/math373.html
new file mode 100644 (file)
index 0000000..ebfe209
--- /dev/null
@@ -0,0 +1,57 @@
+<!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 is always available.  It provides access to the
+mathematical functions defined by the C standard.</p>
+        <div class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#functions">Functions</a></li>
+              </ul>
+            </li>
+          </ul>
+        </div>
+        <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 id="log">
+              <span class="m-doc-wrap-bumper">def <a href="#log" class="m-doc-self">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>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index a4c2fa2f5a8e914e98f272569315d82929000ec8..2ee98c8c3e802412b002c10c9a374d4dce7e24ea 100644 (file)
@@ -86,8 +86,10 @@ class Annotations(BaseInspectTestCase):
         self.assertEqual(*self.actual_expected_contents('inspect_annotations.Foo.html'))
         self.assertEqual(*self.actual_expected_contents('inspect_annotations.FooSlots.html'))
 
-    @unittest.skipUnless(LooseVersion(sys.version) >= LooseVersion('3.7'),
-        "signature with / for pow() is not present in 3.6")
+    # https://github.com/python/cpython/pull/13394
+    @unittest.skipUnless(LooseVersion(sys.version) >= LooseVersion('3.7.4'),
+        "signature with / for pow() is not present in 3.6, "
+        "3.7.3 and below has a different docstring")
     def test_math(self):
         # From math export only pow() so we have the verification easier, and
         # in addition log() because it doesn't provide any signature metadata
@@ -103,6 +105,25 @@ class Annotations(BaseInspectTestCase):
 
         self.assertEqual(*self.actual_expected_contents('math.html'))
 
+    # https://github.com/python/cpython/pull/13394
+    @unittest.skipUnless(LooseVersion(sys.version) < LooseVersion('3.7.4') and LooseVersion(sys.version) >= LooseVersion('3.7'),
+        "signature with / for pow() is not present in 3.6, "
+        "3.7.3 and below has a different docstring")
+    def test_math373(self):
+        # From math export only pow() so we have the verification easier, and
+        # in addition log() because it doesn't provide any signature metadata
+        assert not hasattr(math, '__all__')
+        math.__all__ = ['pow', 'log']
+
+        self.run_python({
+            'INPUT_MODULES': [math]
+        })
+
+        del math.__all__
+        assert not hasattr(math, '__all__')
+
+        self.assertEqual(*self.actual_expected_contents('math.html', 'math373.html'))
+
     @unittest.skipUnless(LooseVersion(sys.version) < LooseVersion('3.7'),
         "docstring for log() is different in 3.7")
     def test_math36(self):