about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tst/test_help.py21
-rw-r--r--tst/test_listen.py3
2 files changed, 15 insertions, 9 deletions
diff --git a/tst/test_help.py b/tst/test_help.py
index 429d7c4..0889961 100644
--- a/tst/test_help.py
+++ b/tst/test_help.py
@@ -19,7 +19,7 @@
 from contextlib import redirect_stdout, suppress
 from io import StringIO
 
-from hypothesis import given
+from hypothesis import example, given
 from pytest import fixture, mark, raises
 
 from scadere import NetLoc
@@ -57,13 +57,18 @@ def test_long_option(help_string, short, long, metavar):
     assert f'{short} {metavar}, {long}={metavar}' in help_string
 
 
+@example('a.example:98', None)  # string is unlikely to match .*:\d+
 @given(...)
-def test_netloc(hostname: str, port: int | None, default_port: int | None):
+def test_netloc(string: str, default_port: int | None):
     netloc = NetLoc(default_port)
-    if port is not None:
-        assert netloc(f'{hostname}:{port}') == (hostname, port)
-    elif default_port is None:
-        with raises(ValueError):
-            netloc(f'{hostname}:{port}')
+    if ':' not in string:
+        assert netloc(string) == (string, default_port)
     else:
-        assert netloc(hostname) == (hostname, default_port)
+        hostname, port = string.rsplit(':', 1)
+        try:
+            port_number = int(port)
+        except ValueError:
+            with raises(ValueError):
+                netloc(string)
+        else:
+            assert netloc(string) == (hostname, port_number)
diff --git a/tst/test_listen.py b/tst/test_listen.py
index ec98140..72e4968 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -31,7 +31,7 @@ from xml.etree.ElementTree import (XML, XMLParser, indent,
                                    tostring as str_from_xml)
 from xml.sax.saxutils import escape
 
-from hypothesis import HealthCheck, given, settings
+from hypothesis import HealthCheck, example, given, settings
 from hypothesis.strategies import (builds, composite, data,
                                    datetimes, integers, lists, text)
 from hypothesis.provisional import domains, urls
@@ -209,6 +209,7 @@ async def test_http_200(base_url, certs):
                                  page.find('.//dl', XHTML_NAMESPACES))
 
 
+@example(type('//', (), {'draw': lambda *a, **kw: 'https://a.example//b'}))
 @given(data())
 @settings(suppress_health_check=[HealthCheck.too_slow])
 async def test_http_404(drawer):