Skip to content

Commit c3e159c

Browse files
authored
Fix pre-commit hooks and pytest for Windows environments (#2871)
1 parent 8f18513 commit c3e159c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ repos:
3333
hooks:
3434
- id: readme
3535
name: Update README command help
36-
entry: bash -c 'test -x .tox/fix/bin/python || tox run -e fix --notest -qq; .tox/fix/bin/python scripts/update_command_help_on_markdown.py'
36+
entry: bash -c '[ -x .tox/fix/bin/python ] && PYTHON=.tox/fix/bin/python || PYTHON=.tox/fix/Scripts/python; test -x "$PYTHON" || tox run -e fix --notest -qq; "$PYTHON" scripts/update_command_help_on_markdown.py'
3737
language: system
3838
files: ^(src/datamodel_code_generator/arguments\.py|README\.md|docs/index\.md)$
3939
pass_filenames: false
4040
- id: config-types
4141
name: Generate config TypedDicts
42-
entry: bash -c 'test -x .tox/dev/bin/python || tox run -e dev --notest -qq; .tox/dev/bin/datamodel-codegen --profile generate-config-dict && .tox/dev/bin/datamodel-codegen --profile parser-config-dict && .tox/dev/bin/datamodel-codegen --profile parse-config-dict'
42+
entry: bash -c '[ -x .tox/dev/bin/python ] && PREFIX=.tox/dev/bin || PREFIX=.tox/dev/Scripts; test -x "$PREFIX/python" || tox run -e dev --notest -qq; "$PREFIX/datamodel-codegen" --profile generate-config-dict && "$PREFIX/datamodel-codegen" --profile parser-config-dict && "$PREFIX/datamodel-codegen" --profile parse-config-dict'
4343
language: system
4444
files: ^src/datamodel_code_generator/config\.py$
4545
pass_filenames: false

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ def _assert_with_external_file(content: str, expected_path: Path) -> None:
470470
msg = f"Content mismatch for {expected_path}\n{hint}\n{diff}"
471471
raise AssertionError(msg) from None
472472
else:
473-
assert expected == normalized_content # pragma: no cover
473+
# we need to normalize the external_file object's content as well
474+
assert _normalize_line_endings(expected._load_value()) == normalized_content # pragma: no cover
474475

475476

476477
class AssertFileContent(Protocol):

0 commit comments

Comments
 (0)