From e1b94e4b66f20f164a598712ad954719ad3fbc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Thu, 14 Dec 2023 10:42:18 +0000 Subject: [PATCH] Add 3.12 to CI (#3863) Adds Python 3.12 to CI. Because `tree-sitter`/`tree-sitter-languages` can't be installed on 3.12 yet, we need to run slightly different commands when installing dependencies/running tests on 3.12. See for more context: https://github.com/Textualize/textual/issues/3491#issuecomment-1854156476 --- .github/workflows/pythonpackage.yml | 11 ++++++++++- pyproject.toml | 1 + tests/snapshot_tests/test_snapshots.py | 2 ++ tests/text_area/test_languages.py | 6 ++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 882da2b350..02e367aa44 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] defaults: run: shell: bash @@ -32,9 +32,18 @@ jobs: cache: 'poetry' - name: Install dependencies run: poetry install --no-interaction --extras syntax + if: ${{ matrix.python-version != '3.12' }} + - name: Install dependencies for 3.12 # https://github.com/Textualize/textual/issues/3491#issuecomment-1854156476 + run: poetry install --no-interaction + if: ${{ matrix.python-version == '3.12' }} - name: Test with pytest run: | poetry run pytest tests -v --cov=./src/textual --cov-report=xml:./coverage.xml --cov-report term-missing + if: ${{ matrix.python-version != '3.12' }} + - name: Test with pytest for 3.12 # https://github.com/Textualize/textual/issues/3491#issuecomment-1854156476 + run: | + poetry run pytest tests -v --cov=./src/textual --cov-report=xml:./coverage.xml --cov-report term-missing -m 'not syntax' + if: ${{ matrix.python-version == '3.12' }} - name: Upload snapshot report if: always() uses: actions/upload-artifact@v3 diff --git a/pyproject.toml b/pyproject.toml index 581772683c..a3469a5d1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,6 +83,7 @@ testpaths = ["tests"] addopts = "--strict-markers" markers = [ "integration_test: marks tests as slow integration tests (deselect with '-m \"not integration_test\"')", + "syntax: marks tests that require syntax highlighting (deselect with '-m \"not syntax\"')", ] [build-system] diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index be8a4b4e85..66cbe6a534 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -795,6 +795,7 @@ def test_nested_fr(snap_compare) -> None: assert snap_compare(SNAPSHOT_APPS_DIR / "nested_fr.py") +@pytest.mark.syntax @pytest.mark.parametrize("language", BUILTIN_LANGUAGES) def test_text_area_language_rendering(language, snap_compare): # This test will fail if we're missing a snapshot test for a valid @@ -846,6 +847,7 @@ def setup_selection(pilot): ) +@pytest.mark.syntax @pytest.mark.parametrize( "theme_name", [theme.name for theme in TextAreaTheme.builtin_themes()] ) diff --git a/tests/text_area/test_languages.py b/tests/text_area/test_languages.py index 6124da0cbd..7e33fcf728 100644 --- a/tests/text_area/test_languages.py +++ b/tests/text_area/test_languages.py @@ -1,5 +1,3 @@ -import sys - import pytest from textual.app import App, ComposeResult @@ -61,7 +59,7 @@ async def test_setting_unknown_language(): text_area.language = "this-language-doesnt-exist" -@pytest.mark.skipif(sys.version_info < (3, 8), reason="tree-sitter requires python3.8 or higher") +@pytest.mark.syntax async def test_register_language(): app = TextAreaApp() @@ -84,7 +82,7 @@ async def test_register_language(): assert text_area.language == "elm" -@pytest.mark.skipif(sys.version_info < (3, 8), reason="tree-sitter requires python3.8 or higher") +@pytest.mark.syntax async def test_register_language_existing_language(): app = TextAreaApp() async with app.run_test():