From: Matthew Fernandez Date: Sat, 30 Jan 2021 02:16:35 +0000 (-0800) Subject: test case for #1931 X-Git-Tag: 2.46.1~7^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dee8b1373ae1b364819f4584f5dda1eb04ec9968;p=graphviz test case for #1931 --- diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 9b48a1b63..2a9d5c79f 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -718,3 +718,33 @@ def test_1913(): input = align.upper() _, stderr = run(graph.format(input)) assert 'Warning: Illegal value {} for ALIGN - ignored'.format(input) in stderr + +@pytest.mark.xfail(strict=True) +def test_1931(): + ''' + New lines within strings should not be discarded during parsing + + ''' + + # a graph with \n inside of strings + graph = 'graph {\n' \ + ' node1 [label="line 1\n' \ + 'line 2\n' \ + '"];\n' \ + ' node2 [label="line 3\n' \ + 'line 4"];\n' \ + ' node1 -- node2\n' \ + ' node2 -- "line 5\n' \ + 'line 6"\n' \ + '}' + + # ask Graphviz to process this to dot output + p = subprocess.Popen(['dot', '-Txdot'], stdin=subprocess.PIPE, + stdout=subprocess.PIPE, universal_newlines=True) + xdot, _ = p.communicate(graph) + assert p.returncode == 0 + + # all new lines in strings should have been preserved + assert 'line 1\nline 2\n' in xdot + assert 'line 3\nline 4' in xdot + assert 'line 5\nline 6' in xdot