Skip to content

Commit c738097

Browse files
committed
Used python3 default regex asserts
1 parent 70b98f5 commit c738097

14 files changed

+35
-52
lines changed

python3/koans/about_attribute_access.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ def __getattribute__(self, attr_name):
3636
def test_all_attribute_reads_are_caught(self):
3737
catcher = self.CatchAllAttributeReads()
3838

39-
self.assertRegexpMatches(catcher.foobar, __)
39+
self.assertRegex(catcher.foobar, __)
4040

4141
def test_intercepting_return_values_can_disrupt_the_call_chain(self):
4242
catcher = self.CatchAllAttributeReads()
4343

44-
self.assertRegexpMatches(catcher.foobaz, __) # This is fine
44+
self.assertRegex(catcher.foobaz, __) # This is fine
4545

4646
try:
4747
catcher.foobaz(1)
4848
except TypeError as ex:
4949
err_msg = ex.args[0]
5050

51-
self.assertRegexpMatches(err_msg, __)
51+
self.assertRegex(err_msg, __)
5252

5353
# foobaz returns a string. What happens to the '(1)' part?
5454
# Try entering this into a python console to reproduce the issue:
@@ -59,7 +59,7 @@ def test_intercepting_return_values_can_disrupt_the_call_chain(self):
5959
def test_changes_to_the_getattribute_implementation_affects_getattr_function(self):
6060
catcher = self.CatchAllAttributeReads()
6161

62-
self.assertRegexpMatches(getattr(catcher, 'any_attribute'), __)
62+
self.assertRegex(getattr(catcher, 'any_attribute'), __)
6363

6464
# ------------------------------------------------------------------
6565

python3/koans/about_class_attributes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ def growl(cls):
7575
return "classmethod growl, arg: cls=" + cls.__name__
7676

7777
def test_since_classes_are_objects_you_can_define_singleton_methods_on_them_too(self):
78-
self.assertRegexpMatches(self.Dog2.growl(), __)
78+
self.assertRegex(self.Dog2.growl(), __)
7979

8080
def test_classmethods_are_not_independent_of_instance_methods(self):
8181
fido = self.Dog2()
82-
self.assertRegexpMatches(fido.growl(), __)
83-
self.assertRegexpMatches(self.Dog2.growl(), __)
82+
self.assertRegex(fido.growl(), __)
83+
self.assertRegex(self.Dog2.growl(), __)
8484

8585
def test_staticmethods_are_unbound_functions_housed_in_a_class(self):
86-
self.assertRegexpMatches(self.Dog2.bark(), __)
86+
self.assertRegex(self.Dog2.bark(), __)
8787

8888
def test_staticmethods_also_overshadow_instance_methods(self):
8989
fido = self.Dog2()
90-
self.assertRegexpMatches(fido.bark(), __)
90+
self.assertRegex(fido.bark(), __)
9191

9292
# ------------------------------------------------------------------
9393

python3/koans/about_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_instances_of_classes_can_be_created_adding_parentheses(self):
1515
self.assertEqual(__, fido.__class__.__name__)
1616

1717
def test_classes_have_docstrings(self):
18-
self.assertRegexpMatches(self.Dog.__doc__, __)
18+
self.assertRegex(self.Dog.__doc__, __)
1919

2020
# ------------------------------------------------------------------
2121

python3/koans/about_control_statements.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def test_if_then_statements(self):
1717
if True:
1818
result = 'true value'
1919
self.assertEqual(__, result)
20-
20+
2121
def test_if_then_elif_else_statements(self):
2222
if False:
2323
result = 'first value'
24-
elif True:
24+
elif True:
2525
result = 'true value'
2626
else:
2727
result = 'default value'
@@ -73,8 +73,8 @@ def test_for_statement_with_tuples(self):
7373

7474
text = __
7575

76-
self.assertRegexpMatches(result[2], text)
76+
self.assertRegex(result[2], text)
7777

78-
self.assertNoRegexpMatches(result[0], text)
79-
self.assertNoRegexpMatches(result[1], text)
80-
self.assertNoRegexpMatches(result[3], text)
78+
self.assertNotRegex(result[0], text)
79+
self.assertNotRegex(result[1], text)
80+
self.assertNotRegex(result[3], text)

python3/koans/about_decorating_with_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def mediocre_song(self):
1414
return "o/~ We all live in a broken submarine o/~"
1515

1616
def test_decorators_can_modify_a_function(self):
17-
self.assertRegexpMatches(self.mediocre_song(), __)
17+
self.assertRegex(self.mediocre_song(), __)
1818
self.assertEqual(__, self.mediocre_song.wow_factor)
1919

2020
# ------------------------------------------------------------------
@@ -30,4 +30,3 @@ def render_tag(self, name):
3030

3131
def test_decorators_can_change_a_function_output(self):
3232
self.assertEqual(__, self.render_tag('llama'))
33-

python3/koans/about_deleting_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def test_del_can_remove_attributes(self):
4848
except AttributeError as e:
4949
err_msg2 = e.args[0]
5050

51-
self.assertRegexpMatches(err_msg1, __)
52-
self.assertRegexpMatches(err_msg2, __)
51+
self.assertRegex(err_msg1, __)
52+
self.assertRegex(err_msg2, __)
5353

5454
# ====================================================================
5555

python3/koans/about_generators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_before_sending_a_value_to_a_generator_next_must_be_called(self):
116116
except TypeError as ex:
117117
ex2 = ex
118118

119-
self.assertRegexpMatches(ex2.args[0], __)
119+
self.assertRegex(ex2.args[0], __)
120120

121121
# ------------------------------------------------------------------
122122

@@ -142,5 +142,3 @@ def test_send_none_is_equivalent_to_next(self):
142142
next(generator)
143143
# 'next(generator)' is exactly equivalent to 'generator.send(None)'
144144
self.assertEqual(__, generator.send(None))
145-
146-

python3/koans/about_iteration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_iterating_with_next(self):
2626
except StopIteration as ex:
2727
err_msg = 'Ran out of iterations'
2828

29-
self.assertRegexpMatches(err_msg, __)
29+
self.assertRegex(err_msg, __)
3030

3131
# ------------------------------------------------------------------
3232

python3/koans/about_methods.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_calling_functions_with_wrong_number_of_arguments(self):
2424

2525
# Note, the text comparison works for Python 3.2
2626
# It has changed in the past and may change in the future
27-
self.assertRegexpMatches(msg,
27+
self.assertRegex(msg,
2828
r'my_global_function\(\) missing 2 required positional arguments')
2929

3030
try:
@@ -33,7 +33,7 @@ def test_calling_functions_with_wrong_number_of_arguments(self):
3333
msg = e.args[0]
3434

3535
# Note, watch out for parenthesis. They need slashes in front!
36-
self.assertRegexpMatches(msg, __)
36+
self.assertRegex(msg, __)
3737

3838
# ------------------------------------------------------------------
3939

@@ -126,7 +126,7 @@ def method_with_documentation(self):
126126
return "ok"
127127

128128
def test_the_documentation_can_be_viewed_with_the_doc_method(self):
129-
self.assertRegexpMatches(self.method_with_documentation.__doc__, __)
129+
self.assertRegex(self.method_with_documentation.__doc__, __)
130130

131131
# ------------------------------------------------------------------
132132

@@ -160,4 +160,3 @@ def test_attributes_with_double_underscore_prefixes_are_subject_to_name_mangling
160160

161161
# Name mangling exists to avoid name clash issues when subclassing.
162162
# It is not for providing effective access protection
163-

python3/koans/about_monkey_patching.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_most_built_in_classes_cannot_be_monkey_patched(self):
3535
except Exception as ex:
3636
err_msg = ex.args[0]
3737

38-
self.assertRegexpMatches(err_msg, __)
38+
self.assertRegex(err_msg, __)
3939

4040
# ------------------------------------------------------------------
4141

@@ -46,4 +46,3 @@ def test_subclasses_of_built_in_classes_can_be_be_monkey_patched(self):
4646

4747
self.assertEqual(__, self.MyInt(1).is_even())
4848
self.assertEqual(__, self.MyInt(2).is_even())
49-

0 commit comments

Comments
 (0)