Beispiel #1
0
 def test_correct_braces_just_correct_braces(self):
     test_string1 = "{}"
     test_string2 = "{{{{}}}}"
     self.assertTrue(correct_braces(test_string1),
                     correct_braces_message(test_string1, True))
     self.assertTrue(correct_braces(test_string2),
                     correct_braces_message(test_string2, True))
Beispiel #2
0
 def test_correct_braces_with_quotes_correct(self):
     test_string1 = '{"{adfafdsf{{{fds{}"}{}{text}{"}"}'
     test_string2 = '"}{"'
     self.assertTrue(correct_braces(test_string1),
                     correct_braces_message(test_string1, True))
     self.assertTrue(correct_braces(test_string2),
                     correct_braces_message(test_string2, True))
Beispiel #3
0
 def test_correct_braces_with_quotes_incorrect(self):
     test_string1 = '"}{"}{}{}{"}{"'
     test_string2 = '{"hello{}{}{}{{}}}}""{}"hello'
     test_string3 = '}"{ok}"{'
     self.assertFalse(correct_braces(test_string1),
                      correct_braces_message(test_string1, False))
     self.assertFalse(correct_braces(test_string2),
                      correct_braces_message(test_string2, False))
     self.assertFalse(correct_braces(test_string3),
                      correct_braces_message(test_string3, False))
Beispiel #4
0
 def test_correct_braces_with_text_correct(self):
     test_string1 = "{random string}"
     test_string2 = "t{his{is}correct}really"
     test_string3 = "{correct{correct{correct{correct{}correct}correct}correct}correct}"
     test_string4 = ":{456adf{adf8.,-%}}*?"
     self.assertTrue(correct_braces(test_string1),
                     correct_braces_message(test_string1, True))
     self.assertTrue(correct_braces(test_string2),
                     correct_braces_message(test_string2, True))
     self.assertTrue(correct_braces(test_string3),
                     correct_braces_message(test_string3, True))
     self.assertTrue(correct_braces(test_string4),
                     correct_braces_message(test_string4, True))
Beispiel #5
0
 def test_correct_braces_with_text_incorrect(self):
     test_string1 = "{random string"
     test_string2 = "random string}"
     test_string3 = "so{me}next{{r}}and}{omstring"
     test_string4 = "{some}}next{{rnd}"
     test_string5 = "}t:::e,,,s6545t{"
     self.assertFalse(correct_braces(test_string1),
                      correct_braces_message(test_string1, False))
     self.assertFalse(correct_braces(test_string2),
                      correct_braces_message(test_string2, False))
     self.assertFalse(correct_braces(test_string3),
                      correct_braces_message(test_string3, False))
     self.assertFalse(correct_braces(test_string4),
                      correct_braces_message(test_string4, False))
     self.assertFalse(correct_braces(test_string5),
                      correct_braces_message(test_string5, False))
Beispiel #6
0
 def test_correct_braces_just_incorrect_braces(self):
     test_string1 = "{"
     test_string2 = "}"
     test_string3 = "{{{}}{"
     test_string4 = "{}}}{}{}{}"
     test_string5 = "{{{{{"
     test_string6 = "}}}}}"
     test_string7 = "}{"
     self.assertFalse(correct_braces(test_string1),
                      correct_braces_message(test_string1, False))
     self.assertFalse(correct_braces(test_string2),
                      correct_braces_message(test_string2, False))
     self.assertFalse(correct_braces(test_string3),
                      correct_braces_message(test_string3, False))
     self.assertFalse(correct_braces(test_string4),
                      correct_braces_message(test_string4, False))
     self.assertFalse(correct_braces(test_string5),
                      correct_braces_message(test_string5, False))
     self.assertFalse(correct_braces(test_string6),
                      correct_braces_message(test_string6, False))
     self.assertFalse(correct_braces(test_string7),
                      correct_braces_message(test_string7, False))
Beispiel #7
0
 def test_correct_braces_none_string(self):
     test_string = None
     with self.assertRaises(ValueError):
         correct_braces(test_string)
Beispiel #8
0
 def test_correct_braces_empty_string(self):
     test_string = ""
     self.assertTrue(correct_braces(test_string),
                     correct_braces_message(test_string, True))