Files
python/assignments/python/bob/bob_test.py

45 lines
1.0 KiB
Python
Raw Normal View History

2013-07-30 08:42:09 -05:00
try:
import bob
except ImportError:
quit("Hey, I can't find bob.py. Create it please?")
if not hasattr(bob, 'Bob'):
quit("Don't freak out, but I can't find a class named Bob in `bob.py`. Are you sure it's here?")
import unittest
class BobTests(unittest.TestCase):
def setUp(self):
self.bob = bob.Bob()
def test_shouts(self):
'Bob responds to shouting'
self.assertEqual(
'Woah, chill out!',
self.bob.hey('SHOUTING')
)
def test_questions(self):
'Bob responds to questions'
self.assertEqual(
'Sure.',
self.bob.hey('A question?')
)
def test_statements(self):
'Bob responds to statements'
self.assertEqual(
'Whatever.',
self.bob.hey('A statement.')
)
def test_silence(self):
'Bob responds to silence'
self.assertEqual(
'Fine, be that way.',
self.bob.hey('')
)
if __name__ == '__main__':
unittest.main()