Exemple #1
0
 def run(self):
     """Calls merge_styles in a loop and sets exc attribute if merge_styles raises an exception."""
     for i in range(0, REPEATS):
         try:
             merge_styles(self.old, self.new, self.class_)
         except Exception, e:
             logging.exception("Exception in thread %s", self.name)
             self.exc = e
Exemple #2
0
def test_merge_styles_basic():
    old = 'font-size:1px; color: red'
    new = 'font-size:2px; font-weight: bold'
    expect = 'color:red;', 'font-size:2px;', 'font-weight:bold'
    result = merge_styles(old, new)
    for each in expect:
        assert each in result
 def test_merge_styles_basic(self):
     old = "font-size:1px; color: red"
     new = "font-size:2px; font-weight: bold"
     expect = "color:red;", "font-size:2px;", "font-weight:bold"
     result = merge_styles(old, new)
     for each in expect:
         ok_(each in result)
 def test_merge_styles_non_trivial(self):
     old = 'background-image:url("data:image/png;base64,iVBORw0KGg")'
     new = "font-size:2px; font-weight: bold"
     expect = ('background-image:url("data:image/png;base64,iVBORw0KGg")', "font-size:2px;", "font-weight:bold")
     result = merge_styles(old, new)
     for each in expect:
         ok_(each in result)
Exemple #5
0
def test_merge_styles_non_trivial():
    old = 'background-image:url("data:image/png;base64,iVBORw0KGg")'
    new = 'font-size:2px; font-weight: bold'
    expect = (
        'background-image:url("data:image/png;base64,iVBORw0KGg")',
        'font-size:2px;',
        'font-weight:bold'
    )
    result = merge_styles(old, new)
    for each in expect:
       assert each in result
Exemple #6
0
def test_merge_styles_with_class():
    old = 'color:red; font-size:1px;'
    new, class_ = 'font-size:2px; font-weight: bold', ':hover'

    # because we're dealing with dicts (random order) we have to
    # test carefully.
    # We expect something like this:
    #  {color:red; font-size:1px} :hover{font-size:2px; font-weight:bold}

    result = merge_styles(old, new, class_)
    ok_(result.startswith('{'))
    ok_(result.endswith('}'))
    ok_(' :hover{' in result)
    split_regex = re.compile('{([^}]+)}')
    eq_(len(split_regex.findall(result)), 2)
    expect_first = 'color:red', 'font-size:1px'
    expect_second = 'font-weight:bold', 'font-size:2px'
    for each in expect_first:
        ok_(each in split_regex.findall(result)[0])
    for each in expect_second:
        ok_(each in split_regex.findall(result)[1])
    def test_merge_styles_with_class(self):
        old = "color:red; font-size:1px;"
        new, class_ = "font-size:2px; font-weight: bold", ":hover"

        # because we're dealing with dicts (random order) we have to
        # test carefully.
        # We expect something like this:
        #  {color:red; font-size:1px} :hover{font-size:2px; font-weight:bold}

        result = merge_styles(old, new, class_)
        ok_(result.startswith("{"))
        ok_(result.endswith("}"))
        ok_(" :hover{" in result)
        split_regex = re.compile("{([^}]+)}")
        eq_(len(split_regex.findall(result)), 2)
        expect_first = "color:red", "font-size:1px"
        expect_second = "font-weight:bold", "font-size:2px"
        for each in expect_first:
            ok_(each in split_regex.findall(result)[0])
        for each in expect_second:
            ok_(each in split_regex.findall(result)[1])