コード例 #1
0
 def test_str_works(self):
     canada = core.Country('Canada', 34482779, 9984670)
     mexico = core.Country('Mexico', 112336538, 1943950)
     usa = core.Country('United States of America', 313914040, 9826675)
     na = core.Continent("North America", [canada, mexico, usa])
     assert str(na) == '''North America
コード例 #2
0
 def test_Country_init_works(self):
     c = core.Country('a', 1, 2)
     assert c.name == 'a'
     assert c.population == 1
     assert c.area == 2
コード例 #3
0
 def test_total_population_works(self):
     canada = core.Country('Canada', 34482779, 9984670)
     mexico = core.Country('Mexico', 112336538, 1943950)
     usa = core.Country('United States of America', 313914040, 9826675)
     na = core.Continent("North America", [canada, mexico, usa])
     assert na.total_population() == 460733357
コード例 #4
0
 def test_repr_works(self):
     a = core.Country('a', 45, 20)
     assert repr([a]) == "[Country('a', 45, 20)]"
コード例 #5
0
 def test_str_works(self):
     a = core.Country('a', 4, 21)
     assert str(a) == 'a has a population of 4 and is 21 square km.'
コード例 #6
0
 def test_population_density_works(self):
     a = core.Country('wow', 100, 200)
     assert a.population_density() == 0.5
コード例 #7
0
 def test_is_larger_works(self):
     a = core.Country('a', 3, 2)
     b = core.Country('b', 1, 3)
     assert a.is_larger(b) == True