def test_rand(self): import random,string def capitalize_checker32(s): return ["".join( ch.upper() if not i % 2 else ch for i, ch in enumerate(s)),"".join( ch.upper() if i % 2 else ch for i, ch in enumerate(s))] for i in range (100): r = random.randrange(10,20) s = ''.join(random.choice(string.ascii_lowercase) for letter in range(r)) self.assertEqual(capitalize(s),capitalize_checker32(s))
def test(self): self.assertEqual(capitalize("abcdef"),['AbCdEf', 'aBcDeF']) self.assertEqual(capitalize("codewars"),['CoDeWaRs', 'cOdEwArS']) self.assertEqual(capitalize("abracadabra"),['AbRaCaDaBrA', 'aBrAcAdAbRa']) self.assertEqual(capitalize("codewarriors"),['CoDeWaRrIoRs', 'cOdEwArRiOrS']) self.assertEqual(capitalize("indexinglessons"),['InDeXiNgLeSsOnS', 'iNdExInGlEsSoNs']) self.assertEqual(capitalize("codingisafunactivity"),['CoDiNgIsAfUnAcTiViTy', 'cOdInGiSaFuNaCtIvItY'])
def get(self, **kwargs): """ Capitalizes the first letter of a string. Capitalizes the first letter of the string and then adds it with rest of the string. Omit the lower_rest parameter to keep the rest of the string intact, or set it to true to convert to lowercase. Examples: ---------- ``` morph.now.sh/strings/capitalize?input=wordtocapitalize ``` """ input = request.args.get('input') output = capitalize(input) return Output(output=output, function='Capitalize')
def test_capitalize(self): self.assertEqual(capitalize.capitalize('hello world'), 'Hello World')
from capitalize import capitalize assert capitalize('hello') == 'Hello' assert capitalize('') == '' print('Все тесты пройдены!') #PYTHONPATH=package-name python3 tests/test_capitalize.py
def test_input_1(self): # Failure message: # expected capitalize("elie") to equal "Elie" self.assertEqual(capitalize("elie"), "Elie")
def test_input_4(self): # Failure message: # expected capitalize("only first word") to equal "Only first word" self.assertEqual(capitalize("only first word"), "Only first word")
def test_input_3(self): # Failure message: # expected capitalize("Michael") to equal "Michael" self.assertEqual(capitalize("Michael"), "Michael")
def test_input_2(self): # Failure message: # expected capitalize("matt") to equal "Matt" self.assertEqual(capitalize("matt"), "Matt")
def test_one_word(self): text = 'paitu' result = capitalize(text) self.assertEquals(result, 'Paitu')
def test_multiple_words(self): text = 'paitu rocks' result = capitalize(text) self.assertEquals(result, 'Paitu Rocks')
def test_kapitaliki(self): wynik = capitalize.capitalize() self.assertEqual(wynik, 'Ala ma kota')