Skip to content

Commit

Permalink
Merge pull request #12815 [BEAM-9561] Improve WontImplement reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Sep 11, 2020
2 parents 224b1d4 + 40cdaf6 commit 8e7014d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions sdks/python/apache_beam/dataframe/doctests.py
Expand Up @@ -234,8 +234,8 @@ def fix(self, want, got):
def sort_and_normalize(text):
return '\n'.join(
sorted(
line.rstrip()
for line in text.split('\n') if line.strip())) + '\n'
[line.rstrip() for line in text.split('\n') if line.strip()],
key=str.strip)) + '\n'

got = sort_and_normalize(got)
want = sort_and_normalize(want)
Expand Down Expand Up @@ -322,25 +322,24 @@ def run(self, test, **kwargs):
# Don't fail doctests that raise this error.
example.exc_msg = (
'apache_beam.dataframe.frame_base.WontImplementError: ...')
self.wont_implement += 1
with self._test_env.context():
result = super(BeamDataframeDoctestRunner, self).run(test, **kwargs)
return result

def report_success(self, out, test, example, got):
def extract_concise_reason(got):
m = re.search(r"(WontImplementError:.*)\n$", got)
m = re.search(r"WontImplementError:\s+(.*)\n$", got)
if m:
return m.group(1)
elif "NameError" in got:
return "NameError"
return "NameError following WontImplementError"
elif re.match(r"DeferredBase\[\d+\]\n", got):
return "DeferredBase[*]"
else:
return got.replace("\n", "\\n")

if example.exc_msg == (
'apache_beam.dataframe.frame_base.WontImplementError: ...'):
if self._checker._seen_wont_implement:
self.wont_implement += 1
self._wont_implement_reasons.append(extract_concise_reason(got))

return super(BeamDataframeDoctestRunner,
Expand All @@ -351,8 +350,6 @@ def fake_pandas_module(self):

def summarize(self):
super(BeamDataframeDoctestRunner, self).summarize()
if self.failures:
return

def print_partition(indent, desc, n, total):
print("%s%d %s (%.1f%%)" % (" " * indent, n, desc, n / total * 100))
Expand Down

0 comments on commit 8e7014d

Please sign in to comment.