You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/10/27 18:27:36 UTC

[GitHub] [beam] robertwb commented on a change in pull request #13077: [BEAM-9561] Dataframe test infrastructure improvements.

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



##########
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:
       This is correct, there may not be whitespace following this colon in all cases (but if there is, it's fine to include it as part of the indentation). This is different than the initial prompt. 

##########
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:
       I added 
   
   ```
   foo(
       4
   )
   ```
   
   plus the re-definition of foo and another invocation `foo(5)`.




----------------------------------------------------------------
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:
users@infra.apache.org