From 2354fe13aa53503f72b820818d94432a32436270 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 18 May 2013 18:42:19 -0400 Subject: [PATCH] Implement test_strip_code(); finish TestWikicode (#7) --- tests/test_wikicode.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_wikicode.py b/tests/test_wikicode.py index a6ad950..8dfa655 100644 --- a/tests/test_wikicode.py +++ b/tests/test_wikicode.py @@ -338,13 +338,23 @@ class TestWikicode(TreeEqualityTestCase): def test_strip_code(self): """test Wikicode.strip_code()""" - pass + # Since individual nodes have test cases for their __strip__ methods, + # we're only going to do an integration test: + code = parse("Foo [[bar]]\n\n{{baz}}\n\n[[a|b]] Σ") + self.assertEqual("Foo bar\n\nb Σ", + code.strip_code(normalize=True, collapse=True)) + self.assertEqual("Foo bar\n\n\n\nb Σ", + code.strip_code(normalize=True, collapse=False)) + self.assertEqual("Foo bar\n\nb Σ", + code.strip_code(normalize=False, collapse=True)) + self.assertEqual("Foo bar\n\n\n\nb Σ", + code.strip_code(normalize=False, collapse=False)) def test_get_tree(self): """test Wikicode.get_tree()""" # Since individual nodes have test cases for their __showtree___ - # methods, and the docstring covers all possibilities, this doesn't - # need to test anything other than it: + # methods, and the docstring covers all possibilities for the output of + # __showtree__, we'll test it only: code = parse("Lorem ipsum {{foo|bar|{{baz}}|spam=eggs}}") expected = "Lorem ipsum \n{{\n\t foo\n\t| 1\n\t= bar\n\t| 2\n\t= " + \ "{{\n\t\t\tbaz\n\t }}\n\t| spam\n\t= eggs\n}}"