From de3cc705c93fb770e2c03881c42eab5b182f2917 Mon Sep 17 00:00:00 2001 From: Robert Rees Date: Thu, 23 Apr 2015 15:57:58 +0100 Subject: [PATCH 1/2] Adds the additional functionality tests to the WordCounter example --- test_classes.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test_classes.py b/test_classes.py index 585faf6..af3541c 100644 --- a/test_classes.py +++ b/test_classes.py @@ -60,6 +60,13 @@ class B(A): class TestWordCounter(unittest.TestCase): @unittest.skip("implement WordCounter") + def test_word_counter_initialisation(self): + word_counter = new WordCounter() + + self.assertEquals(word_counter.count(), 0) + + + @unittest.skip("implement counting words") def test_word_counter_count(self): word_counter = WordCounter() word_counter.add_word("polly") @@ -70,7 +77,7 @@ def test_word_counter_count(self): self.assertEquals(word_counter.count(word="parrot"), 1) @unittest.skip("check that the count tracks dupes correctly") - def test_word_counter(self): + def test_word_counter_duplication(self): word_counter = WordCounter() for i in range(3): @@ -79,6 +86,16 @@ def test_word_counter(self): self.assertEquals(word_counter.count(), 3) self.assertEquals(word_counter.count(word="spam"), 3) + @unittest.skip("implement words that haven't been seen") + def test_word_counter_unknown_word(self): + word_counter = WordCounter() + + word_counter.add_word("hello") + word_counter.add_word("world") + + self.assertEquals(word_counter.count("goodbye"), 0) + + class TestCapiClient(unittest.TestCase): # CAPI has two endpoints: /search and /content_id # Each endpoint takes common parameters: page-size, api-key From 79b822e8eacb3e88167d6b3c3f8f8ca6d8901a32 Mon Sep 17 00:00:00 2001 From: Robert Rees Date: Mon, 1 Jun 2015 14:13:15 +0100 Subject: [PATCH 2/2] Fixes a few typos --- test_classes.py | 2 +- test_regexps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test_classes.py b/test_classes.py index af3541c..fee5e13 100644 --- a/test_classes.py +++ b/test_classes.py @@ -61,7 +61,7 @@ class B(A): class TestWordCounter(unittest.TestCase): @unittest.skip("implement WordCounter") def test_word_counter_initialisation(self): - word_counter = new WordCounter() + word_counter = WordCounter() self.assertEquals(word_counter.count(), 0) diff --git a/test_regexps.py b/test_regexps.py index 522ac17..e81654f 100644 --- a/test_regexps.py +++ b/test_regexps.py @@ -17,7 +17,7 @@ def test_raw_strings(self): def test_patterns(self): s = "dead parrot" - pattern = re.compile('(dead)') + pattern = re.compile(r'(dead)') self.assertIsNotNone(pattern.match(s)) self.assertIsNotNone(re.match(r'(dead)', s))