Example #1
0
 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)
Example #2
0
 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')
Example #3
0
    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()
Example #4
0
 def test_set_italic(self):
     styleobj = Style()
     styleobj.italic = True
     self.assertTrue(styleobj.italic)
Example #5
0
 def test_set_size(self):
     styleobj = Style()
     styleobj.size = 11
     self.assertEqual(styleobj.size, 11)
Example #6
0
 def test_set_bad_size_value(self):
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.size = 'a'
     with self.assertRaises(TypeError):
         styleobj.size = False
Example #7
0
 def test_set_underline(self):
     styleobj = Style()
     styleobj.underline = True
     self.assertTrue(styleobj.underline)
Example #8
0
 def test_fail_set_underline(self):
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.underline = 1
     with self.assertRaises(TypeError):
         styleobj.underline = "True"
Example #9
0
 def test_set_strike(self):
     styleobj = Style()
     styleobj.strike = True
     self.assertTrue(styleobj.strike)
Example #10
0
 def test_fail_set_strike(self):
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.strike = 1
Example #11
0
 def test_set_a_correct_font(self):
     font = "calibri.ttf"
     styleobj = Style()
     styleobj.font = font
     self.assertEqual(font, styleobj.font)
Example #12
0
 def test_fail_set_italic(self):
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.italic = 1
Example #13
0
 def test_fail_set_bad_fill(self):
     styleobj = Style()
     with self.assertRaises(ValueError):
         styleobj.fill = 'abz171'
     with self.assertRaises(TypeError):
         styleobj.fill = False
Example #14
0
 def test_set_fill(self):
     styleobj = Style()
     styleobj.fill = 'fff'
     self.assertEqual(styleobj.fill, 'fff')
Example #15
0
 def test_set_bad_bold(self):
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.bold = 1
     with self.assertRaises(TypeError):
         styleobj.bold = "True"
Example #16
0
 def test_set_bold(self):
     styleobj = Style()
     styleobj.bold = True
     self.assertTrue(styleobj.bold)
     styleobj.bold = False
     self.assertFalse(styleobj.bold)
Example #17
0
 def test_set_an_incorrect_font(self):
     font = 123
     styleobj = Style()
     with self.assertRaises(TypeError):
         styleobj.font = font
         self.assertEqual(font, styleobj.font)