diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index ca2d5be..3bbb3b1 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -13,4 +13,4 @@ jobs: steps: - uses: actions/checkout@v3 - run: pip install --user ruff - - run: ruff --format=github . + - run: ruff check -- --format=github . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d06d98..d4c67f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,12 +9,13 @@ env: FORCE_COLOR: 1 jobs: - build: + test: runs-on: ${{ matrix.os }} + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v3 diff --git a/test/integration/test_files.py b/test/integration/test_files.py index 7bcc5db..85eba14 100644 --- a/test/integration/test_files.py +++ b/test/integration/test_files.py @@ -1,4 +1,6 @@ -""" Test str processors on actual file contents """ +"""Test str processors on actual file contents""" + +import sys from functools import partial from test.integration.utils import samples, try_on_file @@ -10,6 +12,12 @@ @pytest.mark.parametrize("filename", samples) def test_fstringify(filename, state): + # this skips "string_in_string.py" for python >=3.12. + # the behavior on these python versions differs. In fact, 3.12 behavior is preferable. + # When only supported versions are 3.12 and up, expected output should be modified. + if filename == "string_in_string.py" and sys.version_info > (3, 11): + return + out, expected = try_on_file( filename, partial(fstringify_code_by_line, state=state), @@ -19,6 +27,12 @@ def test_fstringify(filename, state): @pytest.mark.parametrize("filename", samples) def test_fstringify_single_line(filename): + # this skips "string_in_string.py" for python >=3.12. + # the behavior on these python versions differs. In fact, 3.12 behavior is preferable. + # When only supported versions are 3.12 and up, expected output should be modified. + if filename == "string_in_string.py" and sys.version_info > (3, 11): + return + state = State(multiline=False) out, expected = try_on_file( filename, diff --git a/test/test_edits.py b/test/test_edits.py index cd58019..64500da 100644 --- a/test/test_edits.py +++ b/test/test_edits.py @@ -572,10 +572,17 @@ def test_mixed_quote_types(state: State): def test_mixed_quote_types_unsafe(state: State): - """Test that a multiline, mixed-quotes expression is transformed.""" + """Transforming an expression with quotes in it is more tricky. + + Currently its transformed when running on python >= 3.12, otherwise not.""" + + expected = '''f"one \\"{'\\"'.join(one)}\\" , two {two}"''' out, count = code_editor.fstringify_code_by_line(s_in_mixed_quotes_unsafe, state) - assert out == s_in_mixed_quotes_unsafe + if sys.version_info < (3, 12): + assert out == s_in_mixed_quotes_unsafe + else: + assert out == expected def test_super_call(state: State):