Skip to content

Commit

Permalink
test: disable coverage for cli test
Browse files Browse the repository at this point in the history
It does not really provide much value there and seems to have quite some
impact, removing this reduces the running time of this test from ~10s
(out of a total of ~25s) to ~1s (when run with tox).
  • Loading branch information
yagebu committed Jun 22, 2024
1 parent 21451a0 commit 74c71d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/fava/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class AddressInUse(click.ClickException): # noqa: D101
def __init__(self, port: int) -> None:
def __init__(self, port: int) -> None: # pragma: no cover
super().__init__(
f"Cannot start Fava because port {port} is already in use."
"\nPlease choose a different port with the '-p' option.",
Expand All @@ -33,7 +33,7 @@ def __init__(self, path: str) -> None:


class NoFileSpecifiedError(click.UsageError): # noqa: D101
def __init__(self) -> None:
def __init__(self) -> None: # pragma: no cover
super().__init__("No file specified")


Expand Down
29 changes: 28 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import os
import sys
from pathlib import Path
from socket import socket
from subprocess import PIPE
from subprocess import Popen
Expand All @@ -11,11 +13,35 @@

import pytest

from fava.cli import _add_env_filenames
from fava.cli import NonAbsolutePathError

if TYPE_CHECKING: # pragma: no cover
from pathlib import Path
from typing import IO


def test__add_env_filenames(
monkeypatch: pytest.MonkeyPatch,
) -> None:
absolute_path = Path.cwd().resolve()
absolute = str(absolute_path)
asdf = str(absolute_path / "asdf")
other = str(absolute_path / "other")

monkeypatch.delenv("BEANCOUNT_FILE", raising=False)
assert _add_env_filenames((asdf,)) == {asdf}

monkeypatch.setenv("BEANCOUNT_FILE", "path")
with pytest.raises(NonAbsolutePathError):
_add_env_filenames((asdf,))

monkeypatch.setenv("BEANCOUNT_FILE", absolute)
assert _add_env_filenames((asdf,)) == {absolute, asdf}

monkeypatch.setenv("BEANCOUNT_FILE", os.pathsep.join([absolute, other]))
assert _add_env_filenames((asdf,)) == {absolute, other, asdf}


@pytest.fixture()
def open_port() -> int:
"""Get an open port."""
Expand All @@ -40,6 +66,7 @@ def output_contains(stdout: IO[str], output: str) -> bool:


@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
@pytest.mark.no_cover()
def test_cli(
monkeypatch: pytest.MonkeyPatch,
test_data_dir: Path,
Expand Down

0 comments on commit 74c71d7

Please sign in to comment.