Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Alphadelta14
Created December 31, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alphadelta14/5e6c249012d85e28a45c7d6cf2428926 to your computer and use it in GitHub Desktop.
Save Alphadelta14/5e6c249012d85e28a45c7d6cf2428926 to your computer and use it in GitHub Desktop.
def test_partitioning():
expr = re.compile(r'\*(.*)\*')
children = [docutils.nodes.Text('hello *world* goodbye')]
left, matched, right = inline.re_partition(children, expr)
print(left, matched, right)
assert len(left) == len(right) == 1
assert len(matched) == 2
assert len(matched[0]) == len(matched[1]) == 1
assert left[0] == 'hello '
assert right[0] == ' goodbye'
assert matched[0][0] == '*world*'
assert matched[1][0] == 'world'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment