Skip to content

Commit 9ae9cc7

Browse files
committed
changed back a few __class__ tests to __class__.__name__ to avoid having to deal with those pesky namespaces
1 parent dce689c commit 9ae9cc7

File tree

7 files changed

+15
-13
lines changed

7 files changed

+15
-13
lines changed

python2/koans/about_attribute_access.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_calling_undefined_functions_normally_results_in_errors(self):
1919
try:
2020
typical.foobar()
2121
except Exception as exception:
22-
self.assertEqual(__, exception.__class__)
22+
self.assertEqual(__, exception.__class__.__name__)
2323
self.assertMatch(__, exception[0])
2424

2525
def test_calling_getattribute_causes_an_attribute_error(self):
@@ -160,7 +160,7 @@ def test_getattr_only_catches_unknown_attributes(self):
160160
catcher.free_pie()
161161

162162
self.assertEqual(__,
163-
catcher.give_me_duff_or_give_me_death().__class__)
163+
catcher.give_me_duff_or_give_me_death().__class__.__name__)
164164

165165
self.assertEqual(__, catcher.no_of_getattr_calls)
166166

python2/koans/about_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Dog(object):
1010

1111
def test_instances_of_classes_can_be_created_adding_parentheses(self):
1212
fido = self.Dog()
13-
self.assertEqual(__, fido.__class__)
13+
self.assertEqual(__, fido.__class__.__name__)
1414

1515
def test_classes_have_docstrings(self):
1616
self.assertMatch(__, self.Dog.__doc__)

python2/koans/about_method_bindings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def test_get_descriptor_resolves_attribute_binding(self):
7777
# binding_owner = obj
7878
# owner_type = cls
7979

80-
self.assertEqual(__, bound_obj.__class__)
81-
self.assertEqual(__, binding_owner.__class__)
80+
self.assertEqual(__, bound_obj.__class__.__name__)
81+
self.assertEqual(__, binding_owner.__class__.__name__)
8282
self.assertEqual(AboutMethodBindings, owner_type)
8383

8484
# ------------------------------------------------------------------

python2/koans/about_methods.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def test_calling_functions_with_wrong_number_of_arguments(self):
2222
try:
2323
my_global_function()
2424
except Exception as exception:
25-
self.assertEqual(__, exception.__class__)
25+
# NOTE: The .__name__ attribute will convert the class
26+
# into a string value.
27+
self.assertEqual(__, exception.__class__.__name__)
2628
self.assertMatch(
2729
r'my_global_function\(\) takes exactly 2 arguments \(0 given\)',
2830
exception[0])
@@ -158,7 +160,7 @@ def test_double_underscore_attribute_prefixes_cause_name_mangling(self):
158160
#This may not be possible...
159161
password = rover.__password()
160162
except Exception as ex:
161-
self.assertEqual(__, ex.__class__)
163+
self.assertEqual(__, ex.__class__.__name__)
162164

163165
# But this still is!
164166
self.assertEqual(__, rover._Dog__password())

python2/koans/about_new_style_classes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def test_new_style_classes_have_more_attributes(self):
3434
# ------------------------------------------------------------------
3535

3636
def test_old_style_classes_have_type_but_no_class_attribute(self):
37-
# Note: The .__name__ attribute will convert the type into a string
38-
# value.
39-
#self.assertEqual(__, type(self.OldStyleClass).__name__)
37+
self.assertEqual(__, type(self.OldStyleClass).__name__)
4038

4139
try:
4240
cls = self.OldStyleClass.__class__.__name__

python3/koans/about_classes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ class Dog:
99
"Dogs need regular walkies. Never, ever let them drive."
1010

1111
def test_instances_of_classes_can_be_created_adding_parentheses(self):
12+
# NOTE: The .__name__ attribute will convert the class
13+
# into a string value.
1214
fido = self.Dog()
13-
self.assertEqual(__, fido.__class__)
15+
self.assertEqual(__, fido.__class__.__name__)
1416

1517
def test_classes_have_docstrings(self):
1618
self.assertRegexpMatches(self.Dog.__doc__, __)

python3/koans/about_method_bindings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def test_get_descriptor_resolves_attribute_binding(self):
6868
# binding_owner = obj
6969
# owner_type = cls
7070

71-
self.assertEqual(__, bound_obj.__class__)
72-
self.assertEqual(__, binding_owner.__class__)
71+
self.assertEqual(__, bound_obj.__class__.__name__)
72+
self.assertEqual(__, binding_owner.__class__.__name__)
7373
self.assertEqual(AboutMethodBindings, owner_type)
7474

7575
# ------------------------------------------------------------------

0 commit comments

Comments
 (0)