diff --git a/tests/isolation_provider/test_container.py b/tests/isolation_provider/test_container.py index 860cf9f..48f8d68 100644 --- a/tests/isolation_provider/test_container.py +++ b/tests/isolation_provider/test_container.py @@ -21,31 +21,6 @@ def provider() -> Container: return Container() -class ContainerWait(Container): - """Container isolation provider that blocks until the container has started.""" - - def exec_container(self, *args, **kwargs): # type: ignore [no-untyped-def] - # Check every 100ms if a container with the expected name has showed up. - # Else, closing the file descriptors may not work. - name = kwargs["name"] - runtime = self.get_runtime() - p = super().exec_container(*args, **kwargs) - for i in range(50): - containers = subprocess.run( - [runtime, "ps"], capture_output=True - ).stdout.decode() - if name in containers: - return p - time.sleep(0.1) - - raise RuntimeError(f"Container {name} did not start within 5 seconds") - - -@pytest.fixture -def provider_wait() -> ContainerWait: - return ContainerWait() - - class TestContainer(IsolationProviderTest): pass diff --git a/tests/isolation_provider/test_dummy.py b/tests/isolation_provider/test_dummy.py index 1002687..198a6af 100644 --- a/tests/isolation_provider/test_dummy.py +++ b/tests/isolation_provider/test_dummy.py @@ -1,11 +1,9 @@ import os -import subprocess import pytest from pytest_mock import MockerFixture from dangerzone.conversion import errors -from dangerzone.document import Document from dangerzone.isolation_provider.base import IsolationProvider from dangerzone.isolation_provider.dummy import Dummy @@ -16,24 +14,6 @@ if not os.environ.get("DUMMY_CONVERSION", False): pytest.skip("Dummy conversion is not enabled", allow_module_level=True) -class DummyWait(Dummy): - """Dummy isolation provider that spawns a blocking process.""" - - def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen: - return subprocess.Popen( - ["python3"], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - start_new_session=True, - ) - - -@pytest.fixture -def provider_wait() -> DummyWait: - return DummyWait() - - @pytest.fixture def provider() -> Dummy: return Dummy() @@ -42,21 +22,12 @@ def provider() -> Dummy: class TestDummyTermination(IsolationProviderTermination): def test_failed( self, - provider_wait: IsolationProvider, + provider: IsolationProvider, mocker: MockerFixture, ) -> None: mocker.patch.object( - provider_wait, + provider, "get_proc_exception", return_value=errors.DocFormatUnsupported(), ) - super().test_failed(provider_wait, mocker) - - def test_linger_unkillable( - self, - provider_wait: IsolationProvider, - mocker: MockerFixture, - ) -> None: - # We have to spawn a blocking process here, else we can't imitate an - # "unkillable" process. - super().test_linger_unkillable(provider_wait, mocker) + super().test_failed(provider, mocker) diff --git a/tests/isolation_provider/test_qubes.py b/tests/isolation_provider/test_qubes.py index e3b0b28..d011a65 100644 --- a/tests/isolation_provider/test_qubes.py +++ b/tests/isolation_provider/test_qubes.py @@ -20,11 +20,6 @@ elif os.environ.get("DUMMY_CONVERSION", False): pytest.skip("Dummy conversion is enabled", allow_module_level=True) -@pytest.fixture -def provider() -> Qubes: - return Qubes() - - class QubesWait(Qubes): """Qubes isolation provider that blocks until the disposable qube has started.""" @@ -53,7 +48,7 @@ class QubesWait(Qubes): @pytest.fixture -def provider_wait() -> QubesWait: +def provider() -> QubesWait: return QubesWait()