From 6b15b55896b1ff9f26891fa4a705b524d6d54020 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 10 Jan 2019 16:24:54 +0100 Subject: browser: Use hypothesis’ domains() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes test. --- crocoite/test_browser.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crocoite/test_browser.py b/crocoite/test_browser.py index 4bf2c64..7727259 100644 --- a/crocoite/test_browser.py +++ b/crocoite/test_browser.py @@ -29,6 +29,7 @@ from multidict import CIMultiDict from hypothesis import given import hypothesis.strategies as st +from hypothesis.provisional import domains import pytest from .browser import RequestResponsePair, SiteLoader, VarChangeEvent, Request, \ @@ -119,10 +120,6 @@ def test_referencetimestamp (relativeA, absoluteA, relativeB): (absoluteA >= absoluteB and relativeA >= relativeB) assert abs ((absoluteB - absoluteA).total_seconds () - (relativeB - relativeA)) < 10e-6 -def hostname (): - # XXX: find a better way to generate hostnames - return st.text (alphabet=st.sampled_from('abcdefghijklmnopqrstuvwxyz0123456789-'), min_size=1, max_size=253) - def urls (): """ Build http/https URL """ scheme = st.sampled_from (['http', 'https']) @@ -130,7 +127,7 @@ def urls (): pathSt = st.builds (lambda x: '/' + x, st.text ()) args = st.fixed_dictionaries ({ 'scheme': scheme, - 'host': hostname (), + 'host': domains (), 'port': st.one_of (st.none (), st.integers (min_value=1, max_value=2**16-1)), 'path': pathSt, 'query_string': st.text (), -- cgit v1.2.3