diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb61dd38..5603d33d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - run: uvx hatch run +py=${{matrix.python-version}} types:check test: - runs-on: ubuntu-latest + runs-on: ${{matrix.os}} strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.9, pypy3.10] @@ -44,8 +44,9 @@ jobs: - name: Upload coverage data uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + if: matrix.os == 'ubuntu-latest' with: - name: coverage-data-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} + name: coverage-data-${{github.run_id}}-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} path: .coverage.* include-hidden-files: true if-no-files-found: ignore @@ -64,7 +65,7 @@ jobs: - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: - pattern: coverage-data-* + pattern: coverage-data-${{github.run_id}}-* merge-multiple: true - name: Combine coverage & fail if it's <100% diff --git a/src/inline_snapshot/testing/_example.py b/src/inline_snapshot/testing/_example.py index 1a747a77..789259ea 100644 --- a/src/inline_snapshot/testing/_example.py +++ b/src/inline_snapshot/testing/_example.py @@ -9,6 +9,7 @@ from argparse import ArgumentParser from io import StringIO from pathlib import Path +from pathlib import PurePosixPath from tempfile import TemporaryDirectory from typing import Any @@ -175,7 +176,7 @@ def run_inline( recorder.fix_all() report_output = StringIO() - console = Console(file=report_output) + console = Console(file=report_output, width=80) # TODO: add all the report output here report_problems(console) @@ -298,7 +299,7 @@ def run_pytest( for name, content in sorted(self._read_files(tmp_path).items()): if name not in self.files or self.files[name] != content: - current_files[name] = content + current_files[str(PurePosixPath(*Path(name).parts))] = content assert changed_files == current_files return Example(self._read_files(tmp_path)) diff --git a/tests/test_formating.py b/tests/test_formating.py index f640e656..1c756de2 100644 --- a/tests/test_formating.py +++ b/tests/test_formating.py @@ -1,3 +1,4 @@ +import platform import re import sys from types import SimpleNamespace @@ -8,6 +9,8 @@ from inline_snapshot.testing import Example from tests._is_normalized import normalization +executable = sys.executable.replace("\\", "\\\\") + def test_black_formatting_error(mocker): mocker.patch.object(CliRunner, "invoke", return_value=SimpleNamespace(exit_code=1)) @@ -77,7 +80,7 @@ def test_format_command(): """, "pyproject.toml": f"""\ [tool.inline-snapshot] -format-command="{sys.executable} fmt_cmd.py {{filename}}" +format-command="{executable} fmt_cmd.py {{filename}}" """, "test_a.py": """\ from inline_snapshot import snapshot @@ -106,13 +109,17 @@ def test_format_command_fail(): @normalization def NoPaths(text): + path_re = "/[^ ]*/" if platform.system() != "Windows" else r".:\\[^ ]*\\" text = re.sub( - "The format_command.*following error:", - lambda m: m[0].replace("\n", ""), + "The.format_command.*following.error:", + lambda m: re.sub(" *\n *", " ", m[0]), text, flags=re.MULTILINE | re.DOTALL, ) - text = re.sub("/[^ ]*/", "/.../", text, flags=re.MULTILINE) + text = re.sub(path_re, "/.../", text, flags=re.MULTILINE) + + text = text.replace("python.exe", "python3") + return text Example( @@ -124,7 +131,7 @@ def NoPaths(text): """, "pyproject.toml": f"""\ [tool.inline-snapshot] -format-command="{sys.executable} fmt_cmd.py {{filename}}" +format-command="{executable} fmt_cmd.py {{filename}}" """, "test_a.py": """ from inline_snapshot import snapshot diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 7160e729..6f6c7028 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -732,7 +732,7 @@ def test_storage_dir_config(project, tmp_path, storage_dir): project.pyproject( f""" [tool.inline-snapshot] -storage-dir = "{storage_dir}" +storage-dir = {str(storage_dir)!r} """ )