Skip to content

Commit

Permalink
Added newline case to Jupyter regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PokkeFe committed Jul 9, 2021
1 parent 06969f9 commit 82150e8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions text_extensions_for_pandas/jupyter/test_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
_ALT_TEST_TEXT = "Once upon a second document"
_ALT_TEST_TOKS = make_tokens_and_features(_ALT_TEST_TEXT, _SPACY_LANGUAGE_MODEL)

_NEWLINE_TEST_TEXT = "The first of many.\nA new line segments the text.\nIt remains one string."
_NEWLINE_TEST_TOKS = make_tokens_and_features(_NEWLINE_TEST_TEXT, _SPACY_LANGUAGE_MODEL)

class JupyterTest(TestBase):
def test_pretty_print_html(self):
self.maxDiff = None
Expand Down Expand Up @@ -112,4 +115,23 @@ def test_pretty_print_html(self):
}
</script>
""")

# Multi-line document text regression test
html = pretty_print_html(_NEWLINE_TEST_TOKS["span"].values, False)
suffix = html[-500:]
# print(f"[[[{suffix}]]]")
self.assertEqual(
suffix,
"""\
onst doc_spans = Span.arrayFromSpanArray([[0,3],[4,9],[10,12],[13,17],[17,18],[18,19],[19,20],[21,24],[25,29],[30,38],[39,42],[43,47],[47,48],[48,49],[49,51],[52,59],[60,63],[64,70],[70,71]])
const doc_text = 'The first of many.\\nA new line segments the text.\\nIt remains one string.'
documents.push({doc_text: doc_text, doc_spans: doc_spans})
}
const instance = new window.SpanArray.SpanArray(documents, false, script_context)
instance.render()
}
</script>
""")

0 comments on commit 82150e8

Please sign in to comment.