From 517a3d1f2fa41d0bfb8b9d29f19f4db207754c33 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 14:34:14 +0200 Subject: [PATCH 01/22] matrix with OS and Python versions to run unit test --- .github/workflows/test.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61d114c611..dae7f8e761 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,11 +14,21 @@ on: jobs: test: - runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + os: [ ubuntu-latest, windows-latest, macos-latest ] + python_version: [ "3.11" ] + include: + - os: ubuntu-latest + python_version: "3.7" + - os: macos-latest + python_version: "3.8" + - os: windows-latest + python_version: "3.9" + - os: ubuntu-latest + python_version: "3.10" fail-fast: false + runs-on: ${{ matrix.os }} steps: - name: Dump GitHub context env: From 240514c1eaff69b3784939acff9121b0e65234fe Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 15:04:58 +0200 Subject: [PATCH 02/22] fix typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dae7f8e761..8bb03d9b87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] - python_version: [ "3.11" ] + python-version: [ "3.11" ] include: - os: ubuntu-latest python_version: "3.7" From fed844cdb43608099822d02307aea9dafbdc1024 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 15:06:11 +0200 Subject: [PATCH 03/22] fix typo (2) --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8bb03d9b87..5d4d021056 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,13 +20,13 @@ jobs: python-version: [ "3.11" ] include: - os: ubuntu-latest - python_version: "3.7" + python-version: "3.7" - os: macos-latest - python_version: "3.8" + python-version: "3.8" - os: windows-latest - python_version: "3.9" + python-version: "3.9" - os: ubuntu-latest - python_version: "3.10" + python-version: "3.10" fail-fast: false runs-on: ${{ matrix.os }} steps: From 112c3d0c14fa54c86f13fef1bdeda1964d92e768 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 15:25:47 +0200 Subject: [PATCH 04/22] fix sourcing --- typer/_completion_shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer/_completion_shared.py b/typer/_completion_shared.py index 10de54420d..45fd0d30b9 100644 --- a/typer/_completion_shared.py +++ b/typer/_completion_shared.py @@ -106,7 +106,7 @@ def install_bash(*, prog_name: str, complete_var: str, shell: str) -> Path: rc_content = "" if rc_path.is_file(): rc_content = rc_path.read_text() - completion_init_lines = [f"source {completion_path}"] + completion_init_lines = [f"source '{completion_path}'"] for line in completion_init_lines: if line not in rc_content: # pragma: no cover rc_content += f"\n{line}" From 91678fc2690b9b9c99a75d336c5f03bbbefefee5 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 15:33:18 +0200 Subject: [PATCH 05/22] revert sourcing fix --- typer/_completion_shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer/_completion_shared.py b/typer/_completion_shared.py index 45fd0d30b9..10de54420d 100644 --- a/typer/_completion_shared.py +++ b/typer/_completion_shared.py @@ -106,7 +106,7 @@ def install_bash(*, prog_name: str, complete_var: str, shell: str) -> Path: rc_content = "" if rc_path.is_file(): rc_content = rc_path.read_text() - completion_init_lines = [f"source '{completion_path}'"] + completion_init_lines = [f"source {completion_path}"] for line in completion_init_lines: if line not in rc_content: # pragma: no cover rc_content += f"\n{line}" From eefcf56f351b6a8291eabc51fa91fc3141c88840 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 15:56:35 +0200 Subject: [PATCH 06/22] read_text with 'utf-8' encoding specifically --- .../test_parameter_types/test_file/test_tutorial004.py | 2 +- .../test_parameter_types/test_file/test_tutorial004_an.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py b/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py index 3182d7b4ed..96a64779bd 100644 --- a/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py +++ b/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py @@ -18,7 +18,7 @@ def test_main(tmpdir): if binary_file.exists(): # pragma: no cover binary_file.unlink() result = runner.invoke(app, ["--file", f"{binary_file}"]) - text = binary_file.read_text() + text = binary_file.read_text(encoding="utf-8") binary_file.unlink() assert result.exit_code == 0 assert "Binary file written" in result.output diff --git a/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py b/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py index e222d7160c..7cf0ecf498 100644 --- a/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py +++ b/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py @@ -18,7 +18,7 @@ def test_main(tmpdir): if binary_file.exists(): # pragma: no cover binary_file.unlink() result = runner.invoke(app, ["--file", f"{binary_file}"]) - text = binary_file.read_text() + text = binary_file.read_text(encoding="utf-8") binary_file.unlink() assert result.exit_code == 0 assert "Binary file written" in result.output From 7c489390129ee59c6edb8a1e511d262179cae8b4 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 3 May 2024 16:44:07 +0200 Subject: [PATCH 07/22] skip completion tests for Windows and MacOS --- tests/test_completion/test_completion.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index d9115b8e77..2a4a665f9b 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -3,9 +3,11 @@ import sys from pathlib import Path +import pytest from docs_src.commands.index import tutorial001 as mod +@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Test designed for Linux/bash") def test_show_completion(): result = subprocess.run( [ @@ -20,6 +22,7 @@ def test_show_completion(): assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout +@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Test designed for Linux/bash") def test_install_completion(): bash_completion_path: Path = Path.home() / ".bashrc" text = "" From 7e3a08e046254fdc832ee06f0010af0b276d3401 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 14:44:17 +0000 Subject: [PATCH 08/22] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20f?= =?UTF-8?q?ormat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_completion/test_completion.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 2a4a665f9b..72fff6078d 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -4,10 +4,13 @@ from pathlib import Path import pytest + from docs_src.commands.index import tutorial001 as mod -@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Test designed for Linux/bash") +@pytest.mark.skipif( + not sys.platform.startswith("linux"), reason="Test designed for Linux/bash" +) def test_show_completion(): result = subprocess.run( [ @@ -22,7 +25,9 @@ def test_show_completion(): assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout -@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Test designed for Linux/bash") +@pytest.mark.skipif( + not sys.platform.startswith("linux"), reason="Test designed for Linux/bash" +) def test_install_completion(): bash_completion_path: Path = Path.home() / ".bashrc" text = "" From 93074e20128b02cd2a83b698b51b1aab5da438e2 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 11:13:18 +0200 Subject: [PATCH 09/22] include OS in coverage name to prevent duplicates --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c45252bcd..0d78b52506 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,7 +62,7 @@ jobs: - name: Store coverage files uses: actions/upload-artifact@v4 with: - name: coverage-${{ matrix.python-version }} + name: coverage-${{ matrix.python-version }}-${{ matrix.os }} path: coverage coverage-combine: From 4b08ebf02f13a46a73610caff0a84bfa205adaf9 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 11:28:34 +0200 Subject: [PATCH 10/22] use matrix os specifically --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d78b52506..425b7403a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} + key: ${{ matrix.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install -r requirements-tests.txt @@ -57,12 +57,12 @@ jobs: - name: Test run: bash scripts/test.sh env: - COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} - CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} + COVERAGE_FILE: coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }} + CONTEXT: ${{ matrix.os }}-py${{ matrix.python-version }} - name: Store coverage files uses: actions/upload-artifact@v4 with: - name: coverage-${{ matrix.python-version }}-${{ matrix.os }} + name: coverage-${{ matrix.os }}-${{ matrix.python-version }} path: coverage coverage-combine: From 07d593b37d737a48f9014bdc2029076a55a003bf Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 14:34:18 +0200 Subject: [PATCH 11/22] ignore errors in generating coverage report (test) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c9e793e1ed..fcc2a89a8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,6 +137,7 @@ exclude_lines = [ 'if __name__ == "__main__":', "if TYPE_CHECKING:", ] +ignore_errors = true [tool.mypy] strict = true From 9aba40b1f81e2001b688682687215970162552b7 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 14:57:00 +0200 Subject: [PATCH 12/22] revert ignoring errors (as it didn't work) --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fcc2a89a8c..c9e793e1ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,7 +137,6 @@ exclude_lines = [ 'if __name__ == "__main__":', "if TYPE_CHECKING:", ] -ignore_errors = true [tool.mypy] strict = true From 4d699487f133e1edd063eace4507aebb437eee26 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 15:48:21 +0200 Subject: [PATCH 13/22] another test with env --- .../test_tutorial/test_commands/test_help/test_tutorial007.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py index 1f320d7f3c..0bc79760ea 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py @@ -1,5 +1,6 @@ import subprocess import sys +import os from typer.testing import CliRunner @@ -9,6 +10,8 @@ runner = CliRunner() +ENV = {**os.environ, "PYTHONIOENCODING": "utf-8"} + def test_main_help(): result = runner.invoke(app, ["--help"]) @@ -51,5 +54,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env=ENV, ) assert "Usage" in result.stdout From 37f6ea56947ccd22851c8e65df62160332559cd5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:48:30 +0000 Subject: [PATCH 14/22] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20f?= =?UTF-8?q?ormat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_tutorial/test_commands/test_help/test_tutorial007.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py index 0bc79760ea..3cdd6db9bf 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py @@ -1,6 +1,6 @@ +import os import subprocess import sys -import os from typer.testing import CliRunner From aa586d795a8af2b2e3f970a0482941ddf0504cbf Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 15:56:32 +0200 Subject: [PATCH 15/22] use env argument for every test currently failing on Windows --- .../test_tutorial/test_commands/test_help/test_tutorial004.py | 2 ++ .../test_commands/test_help/test_tutorial004_an.py | 2 ++ .../test_tutorial/test_commands/test_help/test_tutorial005.py | 2 ++ .../test_commands/test_help/test_tutorial005_an.py | 2 ++ .../test_tutorial/test_commands/test_help/test_tutorial006.py | 2 ++ .../test_tutorial/test_commands/test_help/test_tutorial007.py | 4 +--- .../test_commands/test_help/test_tutorial007_an.py | 2 ++ 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial004.py b/tests/test_tutorial/test_commands/test_help/test_tutorial004.py index 20127fc6b3..9d67b68f64 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial004.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial004.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -55,5 +56,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py b/tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py index f445f89c6e..fbc9fd28db 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -55,5 +56,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial005.py b/tests/test_tutorial/test_commands/test_help/test_tutorial005.py index 2cf6de837e..8d62cabdae 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial005.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial005.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -56,5 +57,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py b/tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py index 002caf4459..65335e6176 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -56,5 +57,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial006.py b/tests/test_tutorial/test_commands/test_help/test_tutorial006.py index d9da8331cb..d645164b57 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial006.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial006.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -47,5 +48,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py index 3cdd6db9bf..f262c251f5 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial007.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial007.py @@ -10,8 +10,6 @@ runner = CliRunner() -ENV = {**os.environ, "PYTHONIOENCODING": "utf-8"} - def test_main_help(): result = runner.invoke(app, ["--help"]) @@ -54,6 +52,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", - env=ENV, + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout diff --git a/tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py b/tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py index 2acb91367c..1a8c3d60a7 100644 --- a/tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py +++ b/tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -51,5 +52,6 @@ def test_script(): [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], capture_output=True, encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, ) assert "Usage" in result.stdout From 7cedc45db70ae1a8bc58c1efe1d2dda2b0d45e13 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 16:46:29 +0200 Subject: [PATCH 16/22] revert using matrix.os (change not strictly necessary) --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 425b7403a3..aec59bfa03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ matrix.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} + key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: pip install -r requirements-tests.txt @@ -57,12 +57,12 @@ jobs: - name: Test run: bash scripts/test.sh env: - COVERAGE_FILE: coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }} - CONTEXT: ${{ matrix.os }}-py${{ matrix.python-version }} + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} - name: Store coverage files uses: actions/upload-artifact@v4 with: - name: coverage-${{ matrix.os }}-${{ matrix.python-version }} + name: coverage-${{ runner.os }}-${{ matrix.python-version }} path: coverage coverage-combine: From 0a76dbd3048c446bc1b56c7dfab235c0eb4527bf Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 16:48:57 +0200 Subject: [PATCH 17/22] disable caching on macOS --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aec59bfa03..cab9076193 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,7 @@ jobs: # cache: "pip" # cache-dependency-path: pyproject.toml - uses: actions/cache@v3 + if: ${{ runner.os != 'macOS' }} id: cache with: path: ${{ env.pythonLocation }} From 88d7aa012608e4e64febb915cbbc88d5c9074226 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 18:05:10 +0200 Subject: [PATCH 18/22] c/p source paths to coverage.paths section (test) --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c9e793e1ed..5b861918b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,6 +117,13 @@ filterwarnings = [ 'ignore::DeprecationWarning:xdist', ] +[tool.coverage.paths] +source = [ + "docs_src", + "tests", + "typer" +] + [tool.coverage.run] parallel = true data_file = "coverage/.coverage" From 5dec7535e42b93a0b132734ec2ddce3cca318ccd Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 13 May 2024 18:20:25 +0200 Subject: [PATCH 19/22] try coverage run with relative files (test) --- pyproject.toml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5b861918b5..24e25e94e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,13 +117,6 @@ filterwarnings = [ 'ignore::DeprecationWarning:xdist', ] -[tool.coverage.paths] -source = [ - "docs_src", - "tests", - "typer" -] - [tool.coverage.run] parallel = true data_file = "coverage/.coverage" @@ -136,6 +129,7 @@ omit = [ "typer/_typing.py" ] context = '${CONTEXT}' +relative_files = true [tool.coverage.report] exclude_lines = [ From 464467995eb90dc5e8808f4ff4dbbaf4339e1f3e Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 14 May 2024 14:18:41 +0200 Subject: [PATCH 20/22] create needs_linux pytest fixture --- tests/test_completion/test_completion.py | 11 +++-------- tests/utils.py | 4 ++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 72fff6078d..f1a0281713 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -3,14 +3,11 @@ import sys from pathlib import Path -import pytest - from docs_src.commands.index import tutorial001 as mod +from tests.utils import needs_linux -@pytest.mark.skipif( - not sys.platform.startswith("linux"), reason="Test designed for Linux/bash" -) +@needs_linux def test_show_completion(): result = subprocess.run( [ @@ -25,9 +22,7 @@ def test_show_completion(): assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout -@pytest.mark.skipif( - not sys.platform.startswith("linux"), reason="Test designed for Linux/bash" -) +@needs_linux def test_install_completion(): bash_completion_path: Path = Path.home() / ".bashrc" text = "" diff --git a/tests/utils.py b/tests/utils.py index 17d6de906c..9b503ff799 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,3 +5,7 @@ needs_py310 = pytest.mark.skipif( sys.version_info < (3, 10), reason="requires python3.10+" ) + +needs_linux = pytest.mark.skipif( + not sys.platform.startswith("linux"), reason="Test requires Linux" +) From f992a31a72ba40a528e89b30c7c9f7da551c4a06 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 14 May 2024 14:20:13 +0200 Subject: [PATCH 21/22] fix import --- tests/test_completion/test_completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index f1a0281713..3c1045182f 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -4,7 +4,7 @@ from pathlib import Path from docs_src.commands.index import tutorial001 as mod -from tests.utils import needs_linux +from ..utils import needs_linux @needs_linux From 324d1fbb7fc961a93c3454c944d97f88775486dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 12:20:21 +0000 Subject: [PATCH 22/22] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20f?= =?UTF-8?q?ormat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_completion/test_completion.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 3c1045182f..703373b226 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -4,6 +4,7 @@ from pathlib import Path from docs_src.commands.index import tutorial001 as mod + from ..utils import needs_linux