+def _read_content(path: T.Union[str, os.PathLike], search: T.AnyStr) -> T.AnyStr:
+ """Read text or binary content, depending on the type of search argument."""
+ if isinstance(search, str):
+ mode, enc = "r", "utf-8"
+ else:
+ mode, enc = "rb", None
+ with open(path, mode=mode, encoding=enc) as f:
+ return f.read()
+
+
+def in_file(path: T.Union[str, os.PathLike], text: T.AnyStr) -> None:
+ """Check that file contains a string."""
+ is_in(text, _read_content(path, text))
+
+
+def not_in_file(path: T.Union[str, os.PathLike], text: T.AnyStr) -> None:
+ """Check that file does not contain a string."""
+ not_in(text, _read_content(path, text))
+
+