From c2e1ce9a2ccd1d9ec84eb8fd907339d55d4cbf1b Mon Sep 17 00:00:00 2001 From: Cyb3r Jak3 Date: Sun, 11 Oct 2020 15:25:20 -0400 Subject: [PATCH] Working with python 2 --- tests/test_page.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_page.py b/tests/test_page.py index 24d559d..c1ee06c 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -3,6 +3,7 @@ from haralyzer.compat import iteritems from haralyzer.errors import PageNotFoundError import re +import six BAD_PAGE_ID = 'sup_dawg' PAGE_ID = 'page_3' @@ -130,7 +131,23 @@ def test_entries(har_data): assert entry.pageref == entry["pageref"] == page.page_id -def test_iteration(har_data): +@pytest.mark.skipif(six.PY3, reason="Runs with Python 2") +def test_iteration_python2(har_data): + init_data = har_data('humanssuck.net.har') + page = HarPage(PAGE_ID, har_data=init_data) + entries = [x for x in page] + assert len(entries) == 4 + iter_object = iter(page) + assert str(next(iter_object)) == 'HarEntry for http://humanssuck.net/' + assert str(next(iter_object)) == 'HarEntry for http://humanssuck.net/test.css' + assert str(next(iter_object)) == 'HarEntry for http://humanssuck.net/screen_login.gif' + assert str(next(iter_object)) == 'HarEntry for http://humanssuck.net/jquery-1.7.1.min.js' + with pytest.raises(StopIteration): + assert next(iter_object) + + +@pytest.mark.skipif(six.PY2, reason="Runs with Python 3") +def test_iteration_python2(har_data): init_data = har_data('humanssuck.net.har') page = HarPage(PAGE_ID, har_data=init_data) entries = [x for x in page]