예제 #1
0
 def test_has_css_class(self):
     element = Element("div")
     element.add_css_classes("foo")
     assert_false(element.has_css_class("bar"))
     element.add_css_classes("bar")
     assert_true(element.has_css_class("bar"))
     element.remove_css_classes("bar")
     assert_false(element.has_css_class("bar"))
예제 #2
0
 def test_add_multiple_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo", "bar", "baz")
     element.add_css_classes("bar")
     matches = re.search(r'class="(.*)"', str(element))
     css_classes = matches.group(1).split(" ")
     css_classes.sort()
     assert_equal(["bar", "baz", "foo"], css_classes)
예제 #3
0
 def test_add_multiple_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo", "bar", "baz")
     element.add_css_classes("bar")
     matches = re.search(r'class="(.*)"', str(element))
     assert matches is not None
     css_classes = matches.group(1).split(" ")
     assert_equal(["bar", "baz", "foo"], css_classes)
예제 #4
0
 def test_has_css_class(self):
     element = Element("div")
     element.add_css_classes("foo")
     assert_false(element.has_css_class("bar"))
     element.add_css_classes("bar")
     assert_true(element.has_css_class("bar"))
     element.remove_css_classes("bar")
     assert_false(element.has_css_class("bar"))
예제 #5
0
 def test_remove_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo", "bar", "baz")
     element.remove_css_classes("bar", "xxx")
     matches = re.search(r'class="(.*)"', str(element))
     css_classes = matches.group(1).split(" ")
     css_classes.sort()
     assert_equal(["baz", "foo"], css_classes)
예제 #6
0
 def test_remove_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo", "bar", "baz")
     element.remove_css_classes("bar", "xxx")
     matches = re.search(r'class="(.*)"', str(element))
     assert matches is not None
     css_classes = matches.group(1).split(" ")
     css_classes.sort()
     assert_equal(["baz", "foo"], css_classes)
예제 #7
0
 def test_add_one_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo")
     assert_equal([b'<div class="foo">', b"</div>"], list(iter(element)))
예제 #8
0
 def test_add_one_css_classes(self):
     element = Element("div")
     element.add_css_classes("foo")
     assert_equal([b'<div class="foo">', b'</div>'], list(iter(element)))