Skip to content

Commit da93ab6

Browse files
replace deprecated unittest assertions
1 parent 98646f8 commit da93ab6

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

tests/verbal_expressions_test.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,125 +16,125 @@ def tearDown(self):
1616
self.exp = None
1717

1818
def test_should_render_verex_as_string(self):
19-
self.assertEquals(str(self.v.add('^$')), '^$')
19+
self.assertEqual(str(self.v.add('^$')), '^$')
2020

2121
def test_should_render_verex_list_as_string(self):
22-
self.assertEquals(str(self.v.add(['^', '[0-9]', '$'])), '^[0-9]$')
22+
self.assertEqual(str(self.v.add(['^', '[0-9]', '$'])), '^[0-9]$')
2323

2424
def test_should_match_characters_in_range(self):
2525
self.exp = self.v.start_of_line().range('a', 'c').regex()
2626
for character in ['a', 'b', 'c']:
27-
self.assertRegexpMatches(character, self.exp)
27+
self.assertRegex(character, self.exp)
2828

2929
def test_should_not_match_characters_outside_of_range(self):
3030
self.exp = self.v.start_of_line().range('a', 'c').regex()
31-
self.assertNotRegexpMatches('d', self.exp)
31+
self.assertNotRegex('d', self.exp)
3232

3333
def test_should_match_characters_in_extended_range(self):
3434
self.exp = self.v.start_of_line().range('a', 'b', 'X', 'Z').regex()
3535
for character in ['a', 'b']:
36-
self.assertRegexpMatches(character, self.exp)
36+
self.assertRegex(character, self.exp)
3737
for character in ['X', 'Y', 'Z']:
38-
self.assertRegexpMatches(character, self.exp)
38+
self.assertRegex(character, self.exp)
3939

4040
def test_should_not_match_characters_outside_of_extended_range(self):
4141
self.exp = self.v.start_of_line().range('a', 'b', 'X', 'Z').regex()
42-
self.assertNotRegexpMatches('c', self.exp)
43-
self.assertNotRegexpMatches('W', self.exp)
42+
self.assertNotRegex('c', self.exp)
43+
self.assertNotRegex('W', self.exp)
4444

4545

4646
def test_should_match_start_of_line(self):
4747
self.exp = self.v.start_of_line().regex()
48-
self.assertRegexpMatches('text ', self.exp, 'Not started :(')
48+
self.assertRegex('text ', self.exp, 'Not started :(')
4949

5050
def test_should_match_end_of_line(self):
5151
self.exp = self.v.start_of_line().end_of_line().regex()
52-
self.assertRegexpMatches('', self.exp, 'It\'s not the end!')
52+
self.assertRegex('', self.exp, 'It\'s not the end!')
5353

5454
def test_should_match_anything(self):
5555
self.exp = self.v.start_of_line().anything().end_of_line().regex()
56-
self.assertRegexpMatches('!@#$%¨&*()__+{}', self.exp, 'Not so anything...')
56+
self.assertRegex('!@#$%¨&*()__+{}', self.exp, 'Not so anything...')
5757

5858
def test_should_match_anything_but_specified_element_when_element_is_not_found(self):
5959
self.exp = self.v.start_of_line().anything_but('X').end_of_line().regex()
60-
self.assertRegexpMatches('Y Files', self.exp, 'Found the X!')
60+
self.assertRegex('Y Files', self.exp, 'Found the X!')
6161

6262
def test_should_not_match_anything_but_specified_element_when_specified_element_is_found(self):
6363
self.exp = self.v.start_of_line().anything_but('X').end_of_line().regex()
64-
self.assertNotRegexpMatches('VerEX', self.exp, 'Didn\'t found the X :(')
64+
self.assertNotRegex('VerEX', self.exp, 'Didn\'t found the X :(')
6565

6666
def test_should_find_element(self):
6767
self.exp = self.v.start_of_line().find('Wally').end_of_line().regex()
68-
self.assertRegexpMatches('Wally', self.exp, '404! Wally not Found!')
68+
self.assertRegex('Wally', self.exp, '404! Wally not Found!')
6969

7070
def test_should_not_find_missing_element(self):
7171
self.exp = self.v.start_of_line().find('Wally').end_of_line().regex()
72-
self.assertNotRegexpMatches('Wall-e', self.exp, 'DAFUQ is Wall-e?')
72+
self.assertNotRegex('Wall-e', self.exp, 'DAFUQ is Wall-e?')
7373

7474
def test_should_match_when_maybe_element_is_present(self):
7575
self.exp = self.v.start_of_line().find('Python2.').maybe('7').end_of_line().regex()
76-
self.assertRegexpMatches('Python2.7', self.exp, 'Version doesn\'t match!')
76+
self.assertRegex('Python2.7', self.exp, 'Version doesn\'t match!')
7777

7878
def test_should_match_when_maybe_element_is_missing(self):
7979
self.exp = self.v.start_of_line().find('Python2.').maybe('7').end_of_line().regex()
80-
self.assertRegexpMatches('Python2.', self.exp, 'Version doesn\'t match!')
80+
self.assertRegex('Python2.', self.exp, 'Version doesn\'t match!')
8181

8282
def test_should_match_on_any_when_element_is_found(self):
8383
self.exp = self.v.start_of_line().any('Q').anything().end_of_line().regex()
84-
self.assertRegexpMatches('Query', self.exp, 'No match found!')
84+
self.assertRegex('Query', self.exp, 'No match found!')
8585

8686
def test_should_not_match_on_any_when_element_is_not_found(self):
8787
self.exp = self.v.start_of_line().any('Q').anything().end_of_line().regex()
88-
self.assertNotRegexpMatches('W', self.exp, 'I\'ve found it!')
88+
self.assertNotRegex('W', self.exp, 'I\'ve found it!')
8989

9090
def test_should_match_when_line_break_present(self):
9191
self.exp = self.v.start_of_line().anything().line_break().anything().end_of_line().regex()
92-
self.assertRegexpMatches('Marco \n Polo', self.exp, 'Give me a break!!')
92+
self.assertRegex('Marco \n Polo', self.exp, 'Give me a break!!')
9393

9494
def test_should_match_when_line_break_and_carriage_return_present(self):
9595
self.exp = self.v.start_of_line().anything().line_break().anything().end_of_line().regex()
96-
self.assertRegexpMatches('Marco \r\n Polo', self.exp, 'Give me a break!!')
96+
self.assertRegex('Marco \r\n Polo', self.exp, 'Give me a break!!')
9797

9898
def test_should_not_match_when_line_break_is_missing(self):
9999
self.exp = self.v.start_of_line().anything().line_break().anything().end_of_line().regex()
100-
self.assertNotRegexpMatches('Marco Polo', self.exp, 'There\'s a break here!')
100+
self.assertNotRegex('Marco Polo', self.exp, 'There\'s a break here!')
101101

102102
def test_should_match_when_tab_present(self):
103103
self.exp = self.v.start_of_line().anything().tab().end_of_line().regex()
104-
self.assertRegexpMatches('One tab only ', self.exp, 'No tab here!')
104+
self.assertRegex('One tab only ', self.exp, 'No tab here!')
105105

106106
def test_should_not_match_when_tab_is_missing(self):
107107
self.exp = self.v.start_of_line().anything().tab().end_of_line().regex()
108108
self.assertFalse(re.match(self.exp, 'No tab here'), 'There\'s a tab here!')
109109

110110
def test_should_match_when_word_present(self):
111111
self.exp = self.v.start_of_line().anything().word().end_of_line().regex()
112-
self.assertRegexpMatches('Oneword', self.exp, 'Not just a word!')
112+
self.assertRegex('Oneword', self.exp, 'Not just a word!')
113113

114114
def test_not_match_when_two_words_are_present_instead_of_one(self):
115115
self.exp = self.v.start_of_line().anything().tab().end_of_line().regex()
116116
self.assertFalse(re.match(self.exp, 'Two words'), 'I\'ve found two of them')
117117

118118
def test_should_match_when_or_condition_fulfilled(self):
119119
self.exp = self.v.start_of_line().anything().find('G').OR().find('h').end_of_line().regex()
120-
self.assertRegexpMatches('Github', self.exp, 'Octocat not found')
120+
self.assertRegex('Github', self.exp, 'Octocat not found')
121121

122122
def test_should_not_match_when_or_condition_not_fulfilled(self):
123123
self.exp = self.v.start_of_line().anything().find('G').OR().find('h').end_of_line().regex()
124124
self.assertFalse(re.match(self.exp, 'Bitbucket'), 'Bucket not found')
125125

126126
def test_should_match_on_upper_case_when_lower_case_is_given_and_any_case_is_true(self):
127127
self.exp = self.v.start_of_line().find('THOR').end_of_line().with_any_case(True).regex()
128-
self.assertRegexpMatches('thor', self.exp, 'Upper case Thor, please!')
128+
self.assertRegex('thor', self.exp, 'Upper case Thor, please!')
129129

130130
def test_should_match_multiple_lines(self):
131131
self.exp = self.v.start_of_line().anything().find('Pong').anything().end_of_line().search_one_line(True).regex()
132-
self.assertRegexpMatches('Ping \n Pong \n Ping', self.exp, 'Pong didn\'t answer')
132+
self.assertRegex('Ping \n Pong \n Ping', self.exp, 'Pong didn\'t answer')
133133

134134
def test_should_match_email_address(self):
135135
self.exp = self.v.start_of_line().word().then('@').word().then('.').word().end_of_line().regex()
136-
self.assertRegexpMatches('mail@mail.com', self.exp, 'Not a valid email')
136+
self.assertRegex('mail@mail.com', self.exp, 'Not a valid email')
137137

138138
def test_should_match_url(self):
139139
self.exp = self.v.start_of_line().then('http').maybe('s').then('://').maybe('www.').word().then('.').word().maybe('/').end_of_line().regex()
140-
self.assertRegexpMatches('https://www.google.com/', self.exp, 'Not a valid email')
140+
self.assertRegex('https://www.google.com/', self.exp, 'Not a valid email')

0 commit comments

Comments
 (0)