urlmatch: Use class in test

This commit is contained in:
Florian Bruhin 2018-02-15 15:51:26 +01:00
parent a8a976b324
commit b7c3c10b87

View File

@ -91,22 +91,25 @@ def test_port(pattern, port):
assert up._port == port
def test_match_all_pages_for_given_scheme_attrs():
up = urlmatch.UrlPattern("http://*/*")
assert up._scheme == 'http'
assert up._host == '' # FIXME '' or None?
assert up._match_subdomains
assert not up._match_all
assert up._path == '/*'
class TestMatchAllPagesForGivenScheme:
@pytest.fixture
def up(self):
return urlmatch.UrlPattern("http://*/*")
@pytest.mark.parametrize('url, expected', [
("http://google.com", True),
("http://yahoo.com", True),
("http://google.com/foo", True),
("https://google.com", False),
("http://74.125.127.100/search", True),
])
def test_match_all_pages_for_given_scheme_urls(url, expected):
up = urlmatch.UrlPattern("http://*/*")
assert up.matches(QUrl(url)) == expected
def test_attrs(self, up):
assert up._scheme == 'http'
assert up._host == '' # FIXME '' or None?
assert up._match_subdomains
assert not up._match_all
assert up._path == '/*'
@pytest.mark.parametrize('url, expected', [
("http://google.com", True),
("http://yahoo.com", True),
("http://google.com/foo", True),
("https://google.com", False),
("http://74.125.127.100/search", True),
])
def test_urls(self, up, url, expected):
assert up.matches(QUrl(url)) == expected