From 6d580af335b7346dc53bb249fb7a2b9ed970d0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sun, 5 Nov 2023 12:12:09 +0100 Subject: [PATCH] test: mark slow tests as slow, print 5 slowest tests on `make test` --- Makefile | 5 +++-- tests/test_cli.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ad1dbcd7..293163f1 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,10 @@ build: test: @# if SLOW is not set, pass `-m "not slow"` to skip slow tests - poetry run pytest ${SRCDIRS} -v \ + poetry run pytest ${SRCDIRS} -v --durations=5 \ --cov=gptme --cov-report=xml --cov-report=term-missing --cov-report=html \ - $(if $(SLOW),, -m "not slow") $(if $(PROFILE),--profile-svg) + $(if $(SLOW),, -m "not slow") \ + $(if $(PROFILE), --profile-svg) typecheck: poetry run mypy --ignore-missing-imports ${SRCDIRS} --exclude ${EXCLUDES} diff --git a/tests/test_cli.py b/tests/test_cli.py index 51d0645a..dfe86f52 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -69,6 +69,7 @@ def test_command_summarize(args: list[str], runner: CliRunner): assert result.exit_code == 0 +@pytest.mark.slow def test_command_save(args: list[str], runner: CliRunner): # tests the /save command args.append(f"{CMDFIX}impersonate ```python\nprint('hello')\n```") @@ -93,6 +94,7 @@ def test_command_fork(args: list[str], runner: CliRunner, name: str): assert result.exit_code == 0 +@pytest.mark.slow def test_fileblock(args: list[str], runner: CliRunner): # tests saving with a ```filename.txt block args.append(f"{CMDFIX}impersonate ```hello.py\nprint('hello')\n```") @@ -141,6 +143,7 @@ def test_python_error(args: list[str], runner: CliRunner): blocks = {"python": _block_py, "sh": _block_sh} +@pytest.mark.slow @pytest.mark.parametrize("lang", ["python", "sh"]) def test_block(args: list[str], lang: str, runner: CliRunner): # tests that shell codeblocks are formatted correctly such that whitespace and newlines are preserved