Best Python code snippet using green
test_text_processing.py
Source:test_text_processing.py
1# -*- coding: utf8 -*-2import unittest3import random4import text_processing as tp5class TestTextProcessing(unittest.TestCase):6 def test_normalize(self):7 test_str = "This is an example."8 pred = tp.normalize(test_str)9 self.assertEqual(pred, "this is an example.")10 test_str = " EXTRA SPACE "11 pred = tp.normalize(test_str)12 self.assertEqual(pred, "extra space")13 test_str = "THIS IS ALL CAPS!!"14 pred = tp.normalize(test_str)15 self.assertEqual(pred, "this is all caps!!")16 test_str = " "17 pred = tp.normalize(test_str)18 self.assertEqual(pred, "")19 test_str = "this is all lower space..."20 pred = tp.normalize(test_str)21 self.assertEqual(pred, "this is all lower space...")22 test_str = " H e L l O !"23 pred = tp.normalize(test_str)24 self.assertEqual(pred, "h e l l o !")25 test_str = ""26 pred = tp.normalize(test_str)27 self.assertEqual(pred, "")28 test_str = "........"29 pred = tp.normalize(test_str)30 self.assertEqual(pred, "........")31 test_str = "EX A M P LE"32 pred = tp.normalize(test_str)33 self.assertEqual(pred, "ex a m p le")34 test_str = "Test Text Normalization"35 pred = tp.normalize(test_str)36 self.assertEqual(pred, "test text normalization")37 test_str = "AbCd EfGh IjKl MnOp"38 pred = tp.normalize(test_str)39 self.assertEqual(pred, "abcd efgh ijkl mnop")40 def test_no_vowels(self):41 test_str = "This is an example."42 pred = tp.no_vowels(test_str)43 self.assertEqual(pred, "Ths s n xmpl.")44 test_str = "We love Python!"45 pred = tp.no_vowels(test_str)46 self.assertEqual(pred, "W lv Pythn!")47 test_str = "AEIOU"48 pred = tp.no_vowels(test_str)49 self.assertEqual(pred, "")50 test_str = "aeiou"51 pred = tp.no_vowels(test_str)52 self.assertEqual(pred, "")53 test_str = "QWERTY"54 pred = tp.no_vowels(test_str)55 self.assertEqual(pred, "QWRTY")56 test_str = "qwerty"57 pred = tp.no_vowels(test_str)58 self.assertEqual(pred, "qwrty")59 test_str = "AI for ALL!"60 pred = tp.no_vowels(test_str)61 self.assertEqual(pred, " fr LL!")62 test_str = "Are there any vowels?"63 pred = tp.no_vowels(test_str)64 self.assertEqual(pred, "r thr ny vwls?")65 test_str = ""66 pred = tp.no_vowels(test_str)67 self.assertEqual(pred, "")68 test_str = "abcdefghijklmnopqrstuvwxyz"69 pred = tp.no_vowels(test_str)...
test_text_processing2.py
Source:test_text_processing2.py
1# -*- coding: utf8 -*-2import unittest3import random4import text_processing2 as tp5class TestTextProcessing(unittest.TestCase):6 def test_digits_to_words(self):7 test_str = ""8 pred = tp.digits_to_words(test_str)9 self.assertEqual(pred, "")10 test_str = "Zip Code: 19104"11 pred = tp.digits_to_words(test_str)12 self.assertEqual(pred, "one nine one zero four")13 test_str = "Pi is 3.1415..."14 pred = tp.digits_to_words(test_str)15 self.assertEqual(pred, "three one four one five")16 test_str = "There are 3 jellies."17 pred = tp.digits_to_words(test_str)18 self.assertEqual(pred, "three")19 test_str = "Your room number is 205."20 pred = tp.digits_to_words(test_str)21 self.assertEqual(pred, "two zero five")22 test_str = "1588-1588"23 pred = tp.digits_to_words(test_str)24 self.assertEqual(pred, "one five eight eight one five eight eight")25 test_str = "My number: 010-1234-5678"26 pred = tp.digits_to_words(test_str)27 self.assertEqual(pred, "zero one zero one two three four five six seven eight")28 test_str = "No digits"29 pred = tp.digits_to_words(test_str)30 self.assertEqual(pred, "")31 test_str = "No digits here too!?$%"32 pred = tp.digits_to_words(test_str)33 self.assertEqual(pred, "")34 def test_to_camel_case(self):35 test_str = "to_camel_case"36 pred = tp.to_camel_case(test_str)37 self.assertEqual(pred, "toCamelCase")38 test_str = "__EXAMPLE__NAME__"39 pred = tp.to_camel_case(test_str)40 self.assertEqual(pred, "exampleName")41 test_str = "alreadyCamel"42 pred = tp.to_camel_case(test_str)43 self.assertEqual(pred, "alreadyCamel")44 test_str = "_______"45 pred = tp.to_camel_case(test_str)46 self.assertEqual(pred, "")47 test_str = ""48 pred = tp.to_camel_case(test_str)49 self.assertEqual(pred, "")50 test_str = "not_Camel_Yet"51 pred = tp.to_camel_case(test_str)52 self.assertEqual(pred, "notCamelYet")53 test_str = "NOT_CAMEL_Yet"54 pred = tp.to_camel_case(test_str)55 self.assertEqual(pred, "notCamelYet")56 test_str = "abc_def_ghi"57 pred = tp.to_camel_case(test_str)58 self.assertEqual(pred, "abcDefGhi")59 test_str = " "60 pred = tp.to_camel_case(test_str)61 self.assertEqual(pred, " ")62 test_str = "....."63 pred = tp.to_camel_case(test_str)64 self.assertEqual(pred, ".....")65 ...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!