From b7c3c10b87345e9d3b2c43c20ee1f965ef541c56 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 15 Feb 2018 15:51:26 +0100 Subject: [PATCH] urlmatch: Use class in test --- tests/unit/utils/test_urlmatch.py | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tests/unit/utils/test_urlmatch.py b/tests/unit/utils/test_urlmatch.py index 1fc53a41f..5c25ce457 100644 --- a/tests/unit/utils/test_urlmatch.py +++ b/tests/unit/utils/test_urlmatch.py @@ -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