Skip to content

Commit

Permalink
✅ Add CI configs to run tests on Windows and MacOS (#824)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
svlandeg and pre-commit-ci[bot] authored May 14, 2024
1 parent b4b6f25 commit b751a13
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 5 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -33,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 }}
Expand All @@ -52,7 +63,7 @@ jobs:
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
path: coverage

coverage-combine:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ omit = [
"typer/_typing.py"
]
context = '${CONTEXT}'
relative_files = true

[tool.coverage.report]
exclude_lines = [
Expand Down
4 changes: 4 additions & 0 deletions tests/test_completion/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import needs_linux


@needs_linux
def test_show_completion():
result = subprocess.run(
[
Expand All @@ -20,6 +23,7 @@ def test_show_completion():
assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout


@needs_linux
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit b751a13

Please sign in to comment.