diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/py/conftest.py | 11 | ||||
-rw-r--r-- | test/py/lib/test_repo.py | 26 |
2 files changed, 34 insertions, 3 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py index 3a9c589..0131c37 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -8,10 +8,10 @@ import os from pytest import fixture +from lib import test_repo from lib.db import Database from lib.net import random_unused_port from lib.process import CmdLine -from lib.test_repo import TestRepoOutputSimple, TestRepoOutputEmpty, TestRepoOutputLong class Param: @@ -188,8 +188,13 @@ def client(client_cmd): return client_cmd -@fixture(params=[TestRepoOutputSimple, TestRepoOutputEmpty, TestRepoOutputLong], - ids=['output_simple', 'output_empty', 'output_long']) +@fixture(params=[ + test_repo.TestRepoOutputSimple, + test_repo.TestRepoOutputEmpty, + test_repo.TestRepoOutputLong, + test_repo.TestRepoOutputNull, + ], + ids=['output_simple', 'output_empty', 'output_long', 'output_null']) def test_repo(tmp_path, request): return request.param(os.path.join(tmp_path, 'repo')) diff --git a/test/py/lib/test_repo.py b/test/py/lib/test_repo.py index 3234de5..b882d57 100644 --- a/test/py/lib/test_repo.py +++ b/test/py/lib/test_repo.py @@ -167,3 +167,29 @@ class TestRepoOutputLong(TestRepoOutput): def run_output_matches(self, output): return output.decode() == self.output + + +OUTPUT_SCRIPT_NULL = R'''#!/usr/bin/env python3 + +output = {output} + +import sys +sys.stdout.buffer.write(output) +''' + + +class TestRepoOutputNull(TestRepoOutput): + __test__ = False + + OUTPUT = b'123\x00456' + + def __init__(self, *args, **kwargs): + self.output = TestRepoOutputNull.OUTPUT + super().__init__(*args, **kwargs) + + def _format_output_script(self): + assert len(self.output) == 7 + return OUTPUT_SCRIPT_NULL.format(output=repr(self.output)) + + def run_output_matches(self, output): + return output == self.output |