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 7e1f1e2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 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
11 changes: 4 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,8 @@ def apply_changes(flag):
try:
console = Console(
highlight=False,
color_system=None,
# width=81 if platform.system() == "Windows" else 80,
)
if "short-report" in flags:

Expand Down Expand Up @@ -337,7 +338,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 +353,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
5 changes: 3 additions & 2 deletions 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 @@ -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)
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
13 changes: 7 additions & 6 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 Down Expand Up @@ -107,8 +109,8 @@ def test_format_command_fail():
@normalization
def NoPaths(text):
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,
)
Expand All @@ -124,7 +126,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 +178,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 +190,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 7e1f1e2

Please sign in to comment.