tysonjh commented on a change in pull request #13077:
URL: https://github.com/apache/beam/pull/13077#discussion_r512933392



##########
File path: sdks/python/apache_beam/dataframe/doctests.py
##########
@@ -502,31 +512,33 @@ def is_example_line(line):
   IMPORT_PANDAS = 'import pandas as pd'
 
   example_srcs = []
-  lines = iter(
-      [line.rstrip()
-       for line in rst.split('\n') if is_example_line(line)] + ['END'])
+  lines = iter([(lineno, line.rstrip()) for lineno,
+                line in enumerate(rst.split('\n')) if is_example_line(line)] +
+               [(None, 'END')])
 
   # https://ipython.readthedocs.io/en/stable/sphinxext.html
-  line = next(lines)
+  lineno, line = next(lines)
   while True:
     if line == 'END':
       break
     if line.startswith('.. ipython::'):
-      line = next(lines)
+      lineno, line = next(lines)
       indent = get_indent(line)
       example = []
-      example_srcs.append(example)
+      example_srcs.append((lineno, example))
       while get_indent(line) >= indent:
         if '@verbatim' in line or ':verbatim:' in line or '@savefig' in line:
           example_srcs.pop()
           break
+        line = re.sub(r'In \[\d+\]: ', '', line)
+        line = re.sub(r'\.\.\.+:', '', line)

Review comment:
       Ack.

##########
File path: sdks/python/apache_beam/dataframe/doctests_test.py
##########
@@ -212,13 +228,21 @@ def test_not_implemented_followed_by_name_error(self):
     self.assertEqual(result.attempted, 6)
     self.assertEqual(result.failed, 1)  # Only the very last one.
 
+  def test_failed_assignment(self):
+    result = doctests.teststring(
+        FAILED_ASSIGNMENT,
+        optionflags=doctest.ELLIPSIS,
+        not_implemented_ok=True)
+    self.assertNotEqual(result.attempted, 0)
+    self.assertEqual(result.failed, 0)
+
   def test_rst_ipython(self):
     try:
       import IPython
     except ImportError:
       raise unittest.SkipTest('IPython not available')
     result = doctests.test_rst_ipython(RST_IPYTHON, 'test_rst_ipython')
-    self.assertEqual(result.attempted, 5)
+    self.assertEqual(result.attempted, 8)

Review comment:
       OK, thanks. I misunderstood how counting worked here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to