def test_set_cell_style(self): styleobj = Style() objects = [[1], {1: 2}, (1, ), ' ', -1] cell = Cell('test', styleobj) cell = Cell() cell.style = styleobj for object in objects: with self.assertRaises(TypeError): cell = Cell('test', object)
def test_set_styles_from_signature(self): styleobj = Style(12, 'abc', True, True, 'test', True, True, 'aabbcc') self.assertTrue(styleobj.bold) self.assertTrue(styleobj.strike) self.assertTrue(styleobj.underline) self.assertTrue(styleobj.italic) self.assertEqual(styleobj.fill, 'aabbcc') self.assertEqual(styleobj.color, 'abc') self.assertEqual(styleobj.font, 'test')
def __init__(self, value=None, styleobj=None, x=0, y=0, **kwargs): # init private vars self._fill = None self._value = None self._format_string = None self._style = None self._parent = None self.x = x self.y = y # set properties self.value = value if styleobj: self.style = styleobj else: self.style = Style()
def test_set_italic(self): styleobj = Style() styleobj.italic = True self.assertTrue(styleobj.italic)
def test_set_size(self): styleobj = Style() styleobj.size = 11 self.assertEqual(styleobj.size, 11)
def test_set_bad_size_value(self): styleobj = Style() with self.assertRaises(TypeError): styleobj.size = 'a' with self.assertRaises(TypeError): styleobj.size = False
def test_set_underline(self): styleobj = Style() styleobj.underline = True self.assertTrue(styleobj.underline)
def test_fail_set_underline(self): styleobj = Style() with self.assertRaises(TypeError): styleobj.underline = 1 with self.assertRaises(TypeError): styleobj.underline = "True"
def test_set_strike(self): styleobj = Style() styleobj.strike = True self.assertTrue(styleobj.strike)
def test_fail_set_strike(self): styleobj = Style() with self.assertRaises(TypeError): styleobj.strike = 1
def test_set_a_correct_font(self): font = "calibri.ttf" styleobj = Style() styleobj.font = font self.assertEqual(font, styleobj.font)
def test_fail_set_italic(self): styleobj = Style() with self.assertRaises(TypeError): styleobj.italic = 1
def test_fail_set_bad_fill(self): styleobj = Style() with self.assertRaises(ValueError): styleobj.fill = 'abz171' with self.assertRaises(TypeError): styleobj.fill = False
def test_set_fill(self): styleobj = Style() styleobj.fill = 'fff' self.assertEqual(styleobj.fill, 'fff')
def test_set_bad_bold(self): styleobj = Style() with self.assertRaises(TypeError): styleobj.bold = 1 with self.assertRaises(TypeError): styleobj.bold = "True"
def test_set_bold(self): styleobj = Style() styleobj.bold = True self.assertTrue(styleobj.bold) styleobj.bold = False self.assertFalse(styleobj.bold)
def test_set_an_incorrect_font(self): font = 123 styleobj = Style() with self.assertRaises(TypeError): styleobj.font = font self.assertEqual(font, styleobj.font)