Skip to content

Commit

Permalink
fix: improve coverage config
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 8, 2024
1 parent f884b32 commit 2eda504
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ SRCFILES = $(shell find ${SRCDIRS} -name '*.py')
EXCLUDES = tests/output scripts/build_changelog.py
SRCFILES = $(shell find ${SRCDIRS} -name '*.py' $(foreach EXCLUDE,$(EXCLUDES),-not -path $(EXCLUDE)))

# Check if playwright is installed (for browser tests)
HAS_PLAYWRIGHT := $(shell poetry run command -v playwright 2> /dev/null)

build:
poetry install

Expand All @@ -24,8 +21,7 @@ test:
-n 8 \
$(if $(SLOW), --timeout 60, --timeout 5 -m "not slow") \
$(if $(EVAL), , -m "not eval") \
$(if $(PROFILE), --profile-svg) \
$(if $(HAS_PLAYWRIGHT), --cov-config=scripts/.coveragerc-playwright)
$(if $(PROFILE), --profile-svg)

eval:
poetry run python3 -m eval
Expand Down
6 changes: 3 additions & 3 deletions gptme/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def step(
or (last_msg.role in ["assistant"])
or last_msg.content == "Interrupted"
or last_msg.pinned
):
): # pragma: no cover
inquiry = prompt_user()
if not inquiry:
# Empty command, ask for input again
Expand Down Expand Up @@ -387,14 +387,14 @@ def is_test(name: str) -> bool:
return logfile


def prompt_user(value=None) -> str:
def prompt_user(value=None) -> str: # pragma: no cover
response = prompt_input(PROMPT_USER, value)
if response:
readline.add_history(response)
return response


def prompt_input(prompt: str, value=None) -> str:
def prompt_input(prompt: str, value=None) -> str: # pragma: no cover
prompt = prompt.strip() + ": "
if value:
print(prompt + value)
Expand Down
2 changes: 1 addition & 1 deletion gptme/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def init(provider: str | None, model: str | None, interactive: bool):
model = config.get_env("MODEL") or get_recommended_model()
set_default_model(model)

if interactive: # pragma: no cover
if interactive:
_load_readline_history()

# for some reason it bugs out shell tests in CI
Expand Down
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ markers = [
"serial",
]

[tool.coverage.run]
# Needed to get playwright to play nice with coverage
# https://stackoverflow.com/a/28589618/965332
concurrency = ["greenlet"]
#branch = true

[tool.coverage.report]
# Regexes for lines to exclude from consideration
exclude_also = [
# Don't complain if tests don't hit defensive assertion code
"raise NotImplementedError",

# Don't complain about interactive stuff
"except KeyboardInterrupt:",
"if interactive:",

# Don't complain if non-runnable code isn't run:
"if __name__ == .__main__.:",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 0 additions & 4 deletions scripts/.coveragerc-playwright

This file was deleted.

0 comments on commit 2eda504

Please sign in to comment.