Advertisement
ugochukwu15

Untitled

Jul 26th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import unittest;
  2.  
  3. class Test(unittest.TestCase):
  4. def test_returns_tuple(self):
  5. isogram = is_isogram('abolishment')
  6. self.assertIsInstance(isogram, tuple, msg='Does not return a tuple')
  7.  
  8. def test_checks_for_isograms(self):
  9. word = 'abolishment'
  10. self.assertEqual(
  11. is_isogram(word),
  12. (word, True),
  13. msg="Isogram word, '{}' not detected correctly".format(word)
  14. )
  15.  
  16. def test_returns_false_for_nonisograms(self):
  17. word = 'alphabet'
  18. self.assertEqual(
  19. is_isogram(word),
  20. (word, False),
  21. msg="Non isogram word, '{}' falsely detected".format(word)
  22. )
  23.  
  24. def test_it_only_accepts_strings(self):
  25. with self.assertRaises(TypeError) as context:
  26. is_isogram(2)
  27. self.assertEqual(
  28. 'Argument should be a string',
  29. context.exception.message,
  30. 'String inputs allowed only'
  31. )
  32.  
  33. def test_empty_string_input(self):
  34. word = " "
  35. self.assertEqual(
  36. is_isogram(word),
  37. (word, False),
  38. msg='Empty string not a avalid isogram'
  39. )
  40.  
  41. def is_Isogram():
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement