From 4720b9fc98ce7702c3cf53db82f29122429462b2 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 31 Jan 2022 09:23:36 -0800 Subject: [PATCH] add a test --- bp/_io.pyx | 1 + bp/tests/test_io.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/bp/_io.pyx b/bp/_io.pyx index 0c0f79f..1541467 100644 --- a/bp/_io.pyx +++ b/bp/_io.pyx @@ -145,6 +145,7 @@ cpdef parse_newick(unicode data): if data.count(',') == 0: raise ValueError("Only trees with more than 1 node supported") + data = data.strip() if not data.endswith(';'): raise ValueError("Newick does not appear terminated with a semicolon") diff --git a/bp/tests/test_io.py b/bp/tests/test_io.py index d2f24f0..2f2932b 100644 --- a/bp/tests/test_io.py +++ b/bp/tests/test_io.py @@ -70,6 +70,10 @@ def test_parse_newick_no_semicolon_bug(self): with self.assertRaises(ValueError): parse_newick(test) + # make sure we work with a newline + test = "((h:1, i:1, j:1, k:1, l: 1),(e:1,f:1),(n:1,o:1,p:1))a:1;\n" + parse_newick(test) + def test_write_newick_underscore_bug(self): test = "(((a)b)'c_foo',((d)e)f)r;" buf = io.StringIO()