]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106368: Argument clinic: improve coverage for `self.valid_line()` calls (#107641)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Fri, 4 Aug 2023 19:41:04 +0000 (20:41 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Aug 2023 19:41:04 +0000 (20:41 +0100)
Lib/test/test_clinic.py
Tools/clinic/clinic.py

index dd17d02519bfa7549a3c0e298d063e37f89814f9..84b6a193ecf914ef6becaf2e03dbb9e5d5770b8c 100644 (file)
@@ -1057,6 +1057,38 @@ class ClinicParserTest(TestCase):
             Okay, we're done here.
         """)
 
+    def test_docstring_with_comments(self):
+        function = self.parse_function(dedent("""
+            module foo
+            foo.bar
+              x: int
+                 # We're about to have
+                 # the documentation for x.
+                 Documentation for x.
+                 # We've just had
+                 # the documentation for x.
+              y: int
+
+            # We're about to have
+            # the documentation for foo.
+            This is the documentation for foo.
+            # We've just had
+            # the documentation for foo.
+
+            Okay, we're done here.
+        """))
+        self.checkDocstring(function, """
+            bar($module, /, x, y)
+            --
+
+            This is the documentation for foo.
+
+              x
+                Documentation for x.
+
+            Okay, we're done here.
+        """)
+
     def test_parser_regression_special_character_in_parameter_column_of_docstring_first_line(self):
         function = self.parse_function(dedent("""
             module os
index 917f1bfeb1d250924665fea8610c854ff2988354..7fbae1e0d870ad047bc053da6e8131072cac5721 100755 (executable)
@@ -4685,9 +4685,7 @@ class DSLParser:
         # this line is permitted to start with whitespace.
         # we'll call this number of spaces F (for "function").
 
-        if not self.valid_line(line):
-            return
-
+        assert self.valid_line(line)
         self.indent.infer(line)
 
         # are we cloning?