Skip to content

Commit

Permalink
Add Type Ignore to OS dependent code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinyzu committed Aug 16, 2024
1 parent 967d669 commit db24074
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
from .server import Server, test_server
from .utils import find_chrome_executable, random_port

# MYPY Shenanigans
if os.name != "posix":
os.killpg = lambda pid: pid
os.getpgid = lambda pid: pid
signal.SIGKILL = 9

flags: List[str] = [
"--incognito",
"--accept-lang=en-US",
Expand Down Expand Up @@ -182,13 +176,13 @@ def chrome_proc() -> Generator[subprocess.Popen[bytes], None, None]:
yield proc
finally:
if os.name == "posix":
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
os.killpg(os.getpgid(proc.pid), signal.SIGTERM) # type: ignore[attr-defined]
else:
proc.terminate()
try:
proc.wait(10)
except subprocess.TimeoutExpired:
if os.name == "posix":
os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
os.killpg(os.getpgid(proc.pid), signal.SIGKILL) # type: ignore[attr-defined]
else:
proc.kill()

0 comments on commit db24074

Please sign in to comment.