Improve recently seen address cache
[tinc] / test / integration / testlib / check.py
index a82e0e4..0f3b414 100755 (executable)
@@ -10,6 +10,12 @@ Val = T.TypeVar("Val")
 Num = T.TypeVar("Num", int, float)
 
 
+def blank(value: T.AnyStr) -> None:
+    """Check that value is an empty or blank string."""
+    if not isinstance(value, str) or value.strip():
+        raise ValueError(f'expected "{value!r}" to be a blank string')
+
+
 def false(value: T.Any) -> None:
     """Check that value is falsy."""
     if value:
@@ -98,6 +104,12 @@ def files_eq(path0: str, path1: str) -> None:
 
 
 def file_exists(path: T.Union[str, Path]) -> None:
-    """Check that file or directory exists."""
-    if not os.path.exists(path):
-        raise ValueError("expected path '{path}' to exist")
+    """Check that file exists."""
+    if not os.path.isfile(path):
+        raise ValueError(f"expected file '{path}' to exist")
+
+
+def dir_exists(path: T.Union[str, Path]) -> None:
+    """Check that directory exists."""
+    if not os.path.isdir(path):
+        raise ValueError(f"expected directory '{path}' to exist")