Skip to content

Commit

Permalink
ci: use correct platform
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Feb 8, 2025
1 parent 00710ab commit 4cc14cd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 5 additions & 7 deletions src/inline_snapshot/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ast
import os
import sys
from pathlib import Path

Expand Down Expand Up @@ -280,6 +279,9 @@ def apply_changes(flag):
try:
console = Console(
highlight=False,
color_system=None,
# width=81 if platform.system() == "Windows" else 80,
width=80,
)
if "short-report" in flags:

Expand Down Expand Up @@ -337,7 +339,7 @@ def report(flag, message, message_n):
if not {"review", "report", flag} & flags:
continue

console.rule(f"[yellow bold]{flag.capitalize()} snapshots")
console.rule(f"[yellow bold]{flag.capitalize()} snapshots", characters="-")

with ChangeRecorder().activate() as cr:
apply_all(used_changes)
Expand All @@ -352,11 +354,7 @@ def report(flag, message, message_n):
Panel(
Syntax(diff, "diff", theme="ansi_light"),
title=str(name),
box=(
box.ASCII
if os.environ.get("TERM", "") == "unknown"
else box.ROUNDED
),
box=(box.ASCII),
)
)

Expand Down
3 changes: 2 additions & 1 deletion src/inline_snapshot/testing/_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def format(self):
)

def pyproject(self, source):
print("write pyproject.toml:")
print(source)
self.write_file("pyproject.toml", source)

def write_file(self, filename, content):
Expand Down
15 changes: 11 additions & 4 deletions tests/test_formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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))
Expand Down Expand Up @@ -77,7 +79,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
Expand All @@ -102,6 +104,10 @@ def test_a():
)


import pytest


@pytest.mark.skip()
def test_format_command_fail():

@normalization
Expand All @@ -115,6 +121,8 @@ def NoPaths(text):
text = re.sub("/[^ ]*/", "/.../", text, flags=re.MULTILINE)
return text

executable = sys.executable.replace("\\", "\\\\")

Example(
{
"fmt_cmd.py": """
Expand All @@ -124,7 +132,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
Expand Down Expand Up @@ -176,7 +184,7 @@ def test_no_black(mocker):

Example(
{
"test_a.py": """
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
Expand All @@ -188,7 +196,6 @@ def test_a():
changed_files=snapshot(
{
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""
)

Expand Down

0 comments on commit 4cc14cd

Please sign in to comment.