From eb7064d08366483673c5a467301e713276697ec4 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 7 Feb 2017 00:38:43 +0100 Subject: [PATCH] Fix lint --- tests/end2end/test_mhtml_e2e.py | 36 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/end2end/test_mhtml_e2e.py b/tests/end2end/test_mhtml_e2e.py index 397e585cc..d08b2b75d 100644 --- a/tests/end2end/test_mhtml_e2e.py +++ b/tests/end2end/test_mhtml_e2e.py @@ -82,6 +82,23 @@ def download_dir(tmpdir): return DownloadDir(tmpdir) +def _test_mhtml_requests(test_dir, test_path, httpbin): + with open(os.path.join(test_dir, 'requests'), encoding='utf-8') as f: + expected_requests = [] + for line in f: + if line.startswith('#'): + continue + path = '/{}/{}'.format(test_path, line.strip()) + expected_requests.append(httpbin.ExpectedRequest('GET', path)) + + actual_requests = httpbin.get_requests() + # Requests are not hashable, we need to convert to ExpectedRequests + actual_requests = [httpbin.ExpectedRequest.from_request(req) + for req in actual_requests] + assert (collections.Counter(actual_requests) == + collections.Counter(expected_requests)) + + @pytest.mark.parametrize('test_name', collect_tests()) def test_mhtml(request, test_name, download_dir, quteproc, httpbin): quteproc.set_setting('storage', 'download-directory', @@ -113,20 +130,5 @@ def test_mhtml(request, test_name, download_dir, quteproc, httpbin): expected_file = os.path.join(test_dir, filename) download_dir.compare_mhtml(expected_file) - if request.config.webengine: - return - - with open(os.path.join(test_dir, 'requests'), encoding='utf-8') as f: - expected_requests = [] - for line in f: - if line.startswith('#'): - continue - path = '/{}/{}'.format(test_path, line.strip()) - expected_requests.append(httpbin.ExpectedRequest('GET', path)) - - actual_requests = httpbin.get_requests() - # Requests are not hashable, we need to convert to ExpectedRequests - actual_requests = [httpbin.ExpectedRequest.from_request(req) - for req in actual_requests] - assert (collections.Counter(actual_requests) == - collections.Counter(expected_requests)) + if not request.config.webengine: + _test_mhtml_requests(test_dir, test_path, httpbin)