Fix builds failing (#793)

* Fix builds failing
Fixes #792

* Suppress `docker compose down` errors in cleanup

* Cover all cases

* Fix linting

* Remove unused import
This commit is contained in:
Lev 2022-05-02 01:28:25 +03:00 committed by GitHub
parent ed5311473c
commit 9f502c8538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -43,8 +43,10 @@ def compose(env_file: str):
@pytest.fixture(autouse=True, scope="session") @pytest.fixture(autouse=True, scope="session")
def frappe_setup(compose: Compose): def frappe_setup(compose: Compose):
compose.stop() compose.stop()
compose("up", "-d", "--quiet-pull") compose("up", "-d", "--quiet-pull")
yield yield
compose.stop() compose.stop()

View File

@ -3,6 +3,7 @@ import ssl
import subprocess import subprocess
import sys import sys
import time import time
from contextlib import suppress
from typing import Callable, Optional from typing import Callable, Optional
from urllib.error import HTTPError, URLError from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
@ -46,6 +47,9 @@ class Compose:
self("exec", "-T", *cmd) self("exec", "-T", *cmd)
def stop(self) -> None: def stop(self) -> None:
# Stop all containers in `test` project if they are running.
# We don't care if it fails.
with suppress(subprocess.CalledProcessError):
subprocess.check_call(self.base_cmd + ("down", "-v", "--remove-orphans")) subprocess.check_call(self.base_cmd + ("down", "-v", "--remove-orphans"))
def bench(self, *cmd: str) -> None: def bench(self, *cmd: str) -> None: