From b7233646ce858952e9bfb629228cf550d6048feb Mon Sep 17 00:00:00 2001 From: Thomas Fan Date: Sun, 26 Aug 2018 19:42:40 -0400 Subject: [PATCH] update-sgf-parsing: updates tests to v1.0.0 --- exercises/sgf-parsing/example.py | 11 +++++++---- exercises/sgf-parsing/sgf_parsing_test.py | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/exercises/sgf-parsing/example.py b/exercises/sgf-parsing/example.py index 243dd420c3..cc21e0b6db 100644 --- a/exercises/sgf-parsing/example.py +++ b/exercises/sgf-parsing/example.py @@ -72,10 +72,13 @@ def peek(): return stack[0] def pop_until(ch): - v = '' - while peek() != ch: - v += pop() - return v + try: + v = '' + while peek() != ch: + v += pop() + return v + except IndexError: + raise ValueError('Unable to find {}'.format(ch)) while stack: assert_that(pop() == '(' and peek() == ';') while pop() == ';': diff --git a/exercises/sgf-parsing/sgf_parsing_test.py b/exercises/sgf-parsing/sgf_parsing_test.py index 0cabd08799..a802ff78dd 100644 --- a/exercises/sgf-parsing/sgf_parsing_test.py +++ b/exercises/sgf-parsing/sgf_parsing_test.py @@ -3,6 +3,8 @@ from sgf_parsing import parse, SgfTree +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 + class SgfParsingTest(unittest.TestCase): def test_empty_input(self): input_string = '' @@ -30,7 +32,7 @@ def test_single_node_tree(self): self.assertEqual(parse(input_string), expected) def test_properties_without_delimiter(self): - input_string = '(;a)' + input_string = '(;A)' with self.assertRaisesWithMessage(ValueError): parse(input_string)