Skip to content

Commit 304a0d0

Browse files
author
root
committed
Lesson 31 complete.
1 parent 94b2396 commit 304a0d0

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

python2/koans/about_scope.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,44 @@ def test_dog_is_not_available_in_the_current_scope(self):
2020
try:
2121
fido = Dog()
2222
except Exception as ex:
23-
self.assertMatch(__, ex[0])
23+
self.assertMatch("global name 'Dog' is not defined", ex[0])
2424

2525
def test_you_can_reference_nested_classes_using_the_scope_operator(self):
2626
fido = jims.Dog()
2727
# name 'jims' module name is taken from jims.py filename
2828

2929
rover = joes.Dog()
30-
self.assertEqual(__, fido.identify())
31-
self.assertEqual(__, rover.identify())
30+
self.assertEqual("jims dog", fido.identify())
31+
self.assertEqual("joes dog", rover.identify())
3232

33-
self.assertEqual(____, type(fido) == type(rover))
34-
self.assertEqual(____, jims.Dog == joes.Dog)
33+
self.assertEqual(False, type(fido) == type(rover))
34+
self.assertEqual(False, jims.Dog == joes.Dog)
3535

3636
# ------------------------------------------------------------------
3737

3838
class str(object):
3939
pass
4040

4141
def test_bare_bones_class_names_do_not_assume_the_current_scope(self):
42-
self.assertEqual(____, AboutScope.str == str)
42+
self.assertEqual(False, AboutScope.str == str)
4343

4444
def test_nested_string_is_not_the_same_as_the_system_string(self):
45-
self.assertEqual(____, self.str == type("HI"))
45+
self.assertEqual(False, self.str == type("HI"))
4646

4747
def test_str_without_self_prefix_stays_in_the_global_scope(self):
48-
self.assertEqual(____, str == type("HI"))
48+
self.assertEqual(True, str == type("HI"))
4949

5050
# ------------------------------------------------------------------
5151

5252
PI = 3.1416
53-
5453
def test_constants_are_defined_with_an_initial_uppercase_letter(self):
55-
self.assertAlmostEqual(_____, self.PI)
54+
self.assertAlmostEqual(3.14, self.PI, places=2)
5655
# Note, floating point numbers in python are not precise.
5756
# assertAlmostEqual will check that it is 'close enough'
5857

5958
def test_constants_are_assumed_by_convention_only(self):
6059
self.PI = "rhubarb"
61-
self.assertEqual(_____, self.PI)
60+
self.assertEqual("rhubarb", self.PI)
6261
# There aren't any real constants in python. Its up to the developer
6362
# to keep to the convention and not modify them.
6463

@@ -75,18 +74,18 @@ def test_incrementing_with_local_counter(self):
7574
global counter
7675
start = counter
7776
self.increment_using_local_counter(start)
78-
self.assertEqual(____, counter == start + 1)
77+
self.assertEqual(False, counter == start + 1)
7978

8079
def test_incrementing_with_global_counter(self):
8180
global counter
8281
start = counter
8382
self.increment_using_global_counter()
84-
self.assertEqual(____, counter == start + 1)
83+
self.assertEqual(True, counter == start + 1)
8584

8685
# ------------------------------------------------------------------
8786

8887
global deadly_bingo
8988
deadly_bingo = [4, 8, 15, 16, 23, 42]
9089

9190
def test_global_attributes_can_be_created_in_the_middle_of_a_class(self):
92-
self.assertEqual(__, deadly_bingo[5])
91+
self.assertEqual(42, deadly_bingo[5])

0 commit comments

Comments
 (0)