✅ Add CI configs to run tests on Windows and MacOS (#824)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sofie Van Landeghem · committed by GitHub · parent b4b6f25 · Browse files · 13 files·+39 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diff stats
13 files+39 added−5 removed
- tests:+24 added−2 removed
- other:+15 added−3 removed
Provenance
- Commit
b751a13- Tree
1222d90- Author
Sofie Van Landeghem <svlandeg@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
b4b6f25
13 files changed+39 added−5 removed
modified:.github/workflows/test.yml+14 added-3 removed
12 unmodified lines131415161717182019202122232425262728293031323334356 unmodified lines42434445464748495011 unmodified lines6263646555666768697045 unmodified lines12 unmodified lines - cron: "0 0 * * 1"
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: GITHUB_CONTEXT: ${{ toJson(github) }}6 unmodified lines # Issue ref: https://github.com/actions/setup-python/issues/436 # cache: "pip" # cache-dependency-path: pyproject.toml - uses: actions/cache@v3 if: ${{ runner.os != 'macOS' }} id: cache with: path: ${{ env.pythonLocation }} key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}11 unmodified lines CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} - 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: needs: [test]45 unmodified linesmodified:tests/test_completion/test_completion.py+4 added
3 unmodified lines4 from pathlib import Path5 6 from docs_src.commands.index import tutorial001 as mod7 8+from ..utils import needs_linux9 10+11+@needs_linux12 def test_show_completion():13 result = subprocess.run(14 [15 "bash",6 unmodified lines22 )23 assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout24 25 26+@needs_linux27 def test_install_completion():28 bash_completion_path: Path = Path.home() / ".bashrc"29 text = ""30 if bash_completion_path.is_file(): # pragma: no cover131 unmodified linesmodified:tests/test_tutorial/test_commands/test_help/test_tutorial004_an.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner49 unmodified lines55 result = subprocess.run(56 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],57 capture_output=True,58 encoding="utf-8",59+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},60 )61 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial004.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner49 unmodified lines55 result = subprocess.run(56 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],57 capture_output=True,58 encoding="utf-8",59+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},60 )61 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial005_an.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner50 unmodified lines56 result = subprocess.run(57 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],58 capture_output=True,59 encoding="utf-8",60+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},61 )62 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial005.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner50 unmodified lines56 result = subprocess.run(57 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],58 capture_output=True,59 encoding="utf-8",60+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},61 )62 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial006.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner41 unmodified lines47 result = subprocess.run(48 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],49 capture_output=True,50 encoding="utf-8",51+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},52 )53 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial007_an.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner45 unmodified lines51 result = subprocess.run(52 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],53 capture_output=True,54 encoding="utf-8",55+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},56 )57 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_commands/test_help/test_tutorial007.py+2 added
1+import os2 import subprocess3 import sys4 5 from typer.testing import CliRunner45 unmodified lines51 result = subprocess.run(52 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],53 capture_output=True,54 encoding="utf-8",55+ env={**os.environ, "PYTHONIOENCODING": "utf-8"},56 )57 assert "Usage" in result.stdoutmodified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py+1 added-1 removed
16 unmodified lines17 binary_file = Path(tmpdir) / "config.txt"18 if binary_file.exists(): # pragma: no cover19 binary_file.unlink()20 result = runner.invoke(app, ["--file", f"{binary_file}"])21- text = binary_file.read_text()21+ text = binary_file.read_text(encoding="utf-8")22 binary_file.unlink()23 assert result.exit_code == 024 assert "Binary file written" in result.output25 assert "some settings" in text10 unmodified linesmodified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py+1 added-1 removed
16 unmodified lines17 binary_file = Path(tmpdir) / "config.txt"18 if binary_file.exists(): # pragma: no cover19 binary_file.unlink()20 result = runner.invoke(app, ["--file", f"{binary_file}"])21- text = binary_file.read_text()21+ text = binary_file.read_text(encoding="utf-8")22 binary_file.unlink()23 assert result.exit_code == 024 assert "Binary file written" in result.output25 assert "some settings" in text10 unmodified linesmodified:tests/utils.py+4 added
3 unmodified lines4 5 needs_py310 = pytest.mark.skipif(6 sys.version_info < (3, 10), reason="requires python3.10+"7 )8+9+needs_linux = pytest.mark.skipif(10+ not sys.platform.startswith("linux"), reason="Test requires Linux"11+)modified:pyproject.toml+1 added
127 unmodified lines128 omit = [129 "typer/_typing.py"130 ]131 context = '${CONTEXT}'132+relative_files = true133 134 [tool.coverage.report]135 exclude_lines = [136 "pragma: no cover",67 unmodified lines