Ejemplo n.º 1
0
 def test_removes_added_selector(self):
     assert "custom_selector" not in selectors
     with add_selector("custom_selector"):
         pass
     assert "custom_selector" in selectors
     remove_selector("custom_selector")
     assert "custom_selector" not in selectors
Ejemplo n.º 2
0
    def test_allows_custom_matcher_using_css(self, string):
        with add_selector("section") as s:
            s.css = lambda css_class: "section .{}".format(css_class)

        assert string.has_selector("section", "subsection")
        assert not string.has_selector("section", "section_8")

        remove_selector("section")
Ejemplo n.º 3
0
    def test_allows_using_custom_matchers(self, string):
        with add_selector("lifeform") as s:
            s.xpath = lambda name: "//option[contains(.,'{}')]".format(name)

        assert string.has_selector("id", "page")
        assert not string.has_selector("id", "does-not-exist")
        assert string.has_selector("lifeform", "Monkey")
        assert not string.has_selector("lifeform", "Gorilla")

        remove_selector("lifeform")
Ejemplo n.º 4
0
 def teardown_selector(self):
     try:
         yield
     finally:
         remove_selector("beatle")
Ejemplo n.º 5
0
 def teardown_selector(self):
     try:
         yield
     finally:
         remove_selector("data_attribute")
Ejemplo n.º 6
0
 def test_does_not_raise_an_error_for_a_non_existent_selector(self):
     remove_selector("does_not_exist")
Ejemplo n.º 7
0
 def teardown_selector(self):
     try:
         yield
     finally:
         remove_selector("custom_selector")
Ejemplo n.º 8
0
 def teardown_selector(self):
     try:
         yield
     finally:
         remove_selector("level")