Refactored code to improve readability
@@ -11,8 +11,8 @@ class BookmarkTestCases(unittest.TestCase):
pass
def test_get_next_bookmark_color(self):
- # Test for 8-colored mode
- patch.dict(app.prefs.startup, {'numColors': 8}, clear=True)
+ def test_with_an_x_colored_terminal(x):
+ patch.dict(app.prefs.startup, {'numColors': x}, clear=True)
colors = set()
expectedNumberOfColors = 5
for _ in range(expectedNumberOfColors):
@@ -27,18 +27,8 @@ class BookmarkTestCases(unittest.TestCase):
# Test that the function rotates 5 colors.
self.assertEqual(len(colors), expectedNumberOfColors)
+ # Test for 8-colored mode
+ test_with_an_x_colored_terminal(8)
+
# Test for 256-colored mode
- patch.dict(app.prefs.startup, {'numColors': 256}, clear=True)
- colors = set()
- expectedNumberOfColors = 5
- for _ in range(expectedNumberOfColors):
- color = self.textBuffer.getBookmarkColor()
- # Make sure that a color index is returned.
- self.assertEqual(type(color), int)
- colors.add(color)
- # Test that all colors were different.
- self.assertEqual(len(colors), expectedNumberOfColors)
- color = self.textBuffer.getBookmarkColor()
- colors.add(color)
- # Test that the function rotates 5 colors.
- self.assertEqual(len(colors), expectedNumberOfColors)
\ No newline at end of file
+ test_with_an_x_colored_terminal(256)
\ No newline at end of file
