Browse Source

update animal tests

main
Charles Reid 2 years ago
parent
commit
7992d8f567
Signed by: charlesreid1
GPG Key ID: 078B7759B68B353A
  1. 12
      tests/test_animals.py

12
tests/test_animals.py

@ -14,6 +14,11 @@ from al_pacino.animals import Animal, Cow, Pig, Dog, Cat, Human @@ -14,6 +14,11 @@ from al_pacino.animals import Animal, Cow, Pig, Dog, Cat, Human
@testmode.standalone
class TestAnimals(unittest.TestCase):
def test_make_noise(self):
# base class
with self.assertRaises(NotImplementedError):
Animal().make_noise()
# child classes
correct = [
(Cow, "moo"),
(Pig, "oink"),
@ -24,7 +29,8 @@ class TestAnimals(unittest.TestCase): @@ -24,7 +29,8 @@ class TestAnimals(unittest.TestCase):
for cls, correct_noise in correct:
with CaptureStdout() as output:
cls().make_noise()
self.assertIn(correct_noise, output)
self.assertIn(correct_noise, "".join(output))
def test_speak(self):
pass
if __name__ == "__main__":
unittest.main()

Loading…
Cancel
Save