def test_get_color_rgb(self): t = MockTurtle() expected_color = (1.0, 0.0, 0.5) t.color(expected_color) color = t.color() self.assertEqual((expected_color, expected_color), color)
def test_forgotten_end_fill(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#ff0000' pensize=1 create_line 100 0 100 100 fill='#ff0000' pensize=1 """ # EXEC t = MockTurtle() t.color('red', 'blue') t.begin_fill() for _ in range(2): t.fd(100) t.right(90) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_get_color_rgb(self): t = MockTurtle() expected_color = (1.0, 0.0, 0.5) t.color(expected_color) color = t.color() self.assertEqual((expected_color, expected_color), color)
def test_forgotten_end_fill(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#ff0000' pensize=1 create_line 100 0 100 100 fill='#ff0000' pensize=1 """ # EXEC t = MockTurtle() t.color('red', 'blue') t.begin_fill() for _ in range(2): t.fd(100) t.right(90) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#ff0080'""" # EXEC t = MockTurtle() t.color(1.0, 0.0, 0.5) t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_bad_range(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#000000' pensize=1""" # EXEC t = MockTurtle() t.color(1.0, 0.0, 1.5) # Over 1.0 not allowed, fails to black. t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_bad(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#000000' pensize=1""" # EXEC t = MockTurtle() t.color((1.0, 0.0)) # Only two numbers, fails to black. t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_name(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#0000ff' pensize=1""" # EXEC t = MockTurtle() t.color('blue') t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#ff0080' pensize=1""" # EXEC t = MockTurtle() t.color(1.0, 0.0, 0.5) t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_bad_range(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#000000' pensize=1""" # EXEC t = MockTurtle() t.color(1.0, 0.0, 1.5) # Over 1.0 not allowed, fails to black. t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_bad(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#000000' pensize=1""" # EXEC t = MockTurtle() t.color((1.0, 0.0)) # Only two numbers, fails to black. t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_color_name(self): # SETUP expected_report = """\ create_line 0 0 100 0 fill='#0000ff' pensize=1""" # EXEC t = MockTurtle() t.color('blue') t.fd(100) report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_fill(self): # SETUP expected_report = """\ create_polygon 0 0 100 0 100 100 fill='#0000ff' outline='' create_line 0 0 100 0 fill='#ff0000' pensize=1 create_line 100 0 100 100 fill='#ff0000' pensize=1""" # EXEC t = MockTurtle() t.color("red", "blue") t.begin_fill() for _ in range(2): t.fd(100) t.right(90) t.end_fill() report = t.report # VERIFY self.assertEqual(expected_report.splitlines(), report)
def test_get_color_names(self): t = MockTurtle() t.color("blue") color = t.color() self.assertIn(color, (("blue", "blue"), ("blue1", "blue1")))
def test_get_color_names(self): t = MockTurtle() t.color('blue') color = t.color() self.assertIn(color, (('blue', 'blue'), ('blue1', 'blue1')))
def test_get_default_color(self): t = MockTurtle() color = t.color() self.assertEqual(('black', 'black'), color)
def test_get_default_color(self): t = MockTurtle() color = t.color() self.assertEqual(('black', 'black'), color)
def test_get_color_names(self): t = MockTurtle() t.color('blue') color = t.color() self.assertIn(color, (('blue', 'blue'), ('blue1', 'blue1')))