Example #1
0
 def test_css_nesting_values(self):
     with styles.CSS('outer', width=100, height=100) as outer:
         with styles.CSS('inner', bgc=(1, 0, 0), size=3) as inner:
             q = styles.CSS('innermost', size=4)
     assert q['width'] == outer['width']
     assert q['bgc'] == inner['bgc']
     assert q['size'] == 4
Example #2
0
 def test_css_nesting(self):
     with styles.CSS('outer', width=100, height=100) as outer:
         with styles.CSS('inner', bgc=(1, 0, 0), size=3) as inner:
             q = styles.CSS('innermost', size=4)
         z = styles.CSS('2dlevel', q, bgc=(2, 0, 0))
     assert inner in outer.children
     assert q in inner.children
     assert z in outer.children
Example #3
0
    def test_style_finds_lowest_in_hierarchy_despite_class_hierarchy(self):
        """
        see docs. Style hierarchy position matters, not class hieratchy!
        """
        with styles.CSS(MockCtrl, name='outer') as outer:
            with styles.CSS(MockRedButton, name='middle'):
                styles.CSS(MockButton, name='inner')

        test = MockRedButton('mrb')
        assert outer.find(test)['name'] == 'inner'
Example #4
0
    def test_style_finds_lowest_in_hierarchy(self):
        """
        note as written, this privileges POSITION hierarchy over CLASS hierarchy... is that bad?
        """
        with styles.CSS(MockCtrl, name='outer') as outer:
            with styles.CSS(MockButton, name='middle'):
                styles.CSS(MockRedButton, name='inner')

        test = MockRedButton('mrb')
        assert outer.find(test)['name'] == 'inner'
Example #5
0
 def test_CSS_as_style_context(self):
     
     with styles.CSS(StyledMockCtrl, width = 100, height = 100, expected = False) as outer:
         with styles.CSS(StyledMockButton, bgc = (1,0,0), size = 3, expected = None):
             deepest = styles.CSS(StyledMockRedButton, size = 4, expected = True)
                     
     with outer:
         test = StyledMockRedButton('fred')  # should find 'deepest'
         test2 = StyledMockList('barney')  # defaults to outer
     
     assert test.Style == deepest
     assert test2.Style == outer
Example #6
0
    def test_css_inherit_order(self):
        a = styles.CSS('a', color='red', margin=1)
        b = styles.CSS('b', color='blue', width=128, float='left')
        c = styles.CSS('c', color='green', width=256)
        d = styles.CSS('test', a, b, c)
        assert d['color'] == 'green'
        assert d['width'] == 256
        assert d['float'] == 'left'
        assert d['margin'] == 1

        e = styles.CSS('test', c, a, b)
        assert e['color'] == 'blue'
        assert e['width'] == 128
Example #7
0
 def test_css_nesting_and_manual_values(self):
     with styles.CSS('outer', width=100, height=100) as outer:
         with styles.CSS('inner', bgc=(1, 0, 0), size=3) as inner:
             q = styles.CSS('innermost', size=4)
         z = styles.CSS('upper', q, bgc=(2, 0, 0))
     assert z['bgc'] == (2, 0, 0)
Example #8
0
 def test_css_derive_override(self):
     p = styles.CSS('outer', width=10, height=10)
     c = styles.CSS('inner', p, color='red', height=3)
     assert c['height'] == 3
Example #9
0
 def test_css_derive_inherit(self):
     p = styles.CSS('outer', width=10, height=10)
     c = styles.CSS('inner', p, color='red', height=3)
     assert c['width'] == p['width']
Example #10
0
 def test_css_derive_unique(self):
     p = styles.CSS('outer', width=10, height=10)
     c = styles.CSS('inner', p, color='red', height=3)
     assert c['color'] == 'red'
Example #11
0
 def test_css_params(self):
     example = styles.CSS(object().__class__, width=10, height=10)
     assert example['width'] == 10
     assert example['height'] == 10
Example #12
0
 def test_style_applies_on_name(self):
     example = MockCtrl('hello')
     style = styles.CSS('hello', found=1)
     assert style.applies(example)