示例#1
0
    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))
示例#2
0
 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'])
示例#3
0
文件: index.py 项目: johnayoung/morph
    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')
示例#4
0
 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
示例#6
0
    def test_input_1(self):

        # Failure message:
        # expected capitalize("elie") to equal "Elie"
        self.assertEqual(capitalize("elie"), "Elie")
示例#7
0
    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")
示例#8
0
    def test_input_3(self):

        # Failure message:
        # expected capitalize("Michael") to equal "Michael"
        self.assertEqual(capitalize("Michael"), "Michael")
示例#9
0
    def test_input_2(self):

        # Failure message:
        # expected capitalize("matt") to equal "Matt"
        self.assertEqual(capitalize("matt"), "Matt")
示例#10
0
    def test_one_word(self):
        text = 'paitu'
        result = capitalize(text)

        self.assertEquals(result, 'Paitu')
示例#11
0
    def test_multiple_words(self):
        text = 'paitu rocks'
        result = capitalize(text)

        self.assertEquals(result, 'Paitu Rocks')
示例#12
0
文件: test.py 项目: 7kaza/selenium
 def test_kapitaliki(self):
     wynik = capitalize.capitalize()
     self.assertEqual(wynik, 'Ala ma kota')