Guest User

acronymtest

a guest
Jun 3rd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. import unittest
  2.  
  3. from acronym import abbreviate
  4.  
  5. # Tests adapted from `problem-specifications//canonical-data.json` @ v1.7.0
  6.  
  7.  
  8. class AcronymTest(unittest.TestCase):
  9.     def test_basic(self):
  10.         self.assertEqual(abbreviate("Portable Network Graphics"), "PNG")
  11.  
  12.     def test_lowercase_words(self):
  13.         self.assertEqual(abbreviate("Ruby on Rails"), "ROR")
  14.  
  15.     def test_punctuation(self):
  16.         self.assertEqual(abbreviate("First In, First Out"), "FIFO")
  17.  
  18.     def test_all_caps_word(self):
  19.         self.assertEqual(abbreviate("GNU Image Manipulation Program"), "GIMP")
  20.  
  21.     def test_punctuation_without_whitespace(self):
  22.         self.assertEqual(abbreviate("Complementary metal-oxide semiconductor"), "CMOS")
  23.  
  24.     def test_very_long_abbreviation(self):
  25.         self.assertEqual(
  26.             abbreviate(
  27.                 "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
  28.             ),
  29.             "ROTFLSHTMDCOALM",
  30.         )
  31.  
  32.     def test_consecutive_delimiters(self):
  33.         self.assertEqual(abbreviate("Something - I made up from thin air"), "SIMUFTA")
  34.  
  35.     def test_apostrophes(self):
  36.         self.assertEqual(abbreviate("Halley's Comet"), "HC")
  37.  
  38.     def test_underscore_emphasis(self):
  39.         self.assertEqual(abbreviate("The Road _Not_ Taken"), "TRNT")
  40.  
  41.  
  42. if __name__ == "__main__":
  43.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment