Skip to content

Commit

Permalink
Merge pull request #42 from biocore/strip_the_tree
Browse files Browse the repository at this point in the history
add a test
  • Loading branch information
wasade authored Jan 31, 2022
2 parents fea8a9c + 4720b9f commit a36c37e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions bp/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 4 additions & 0 deletions bp/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a36c37e

Please sign in to comment.