Skip to content

Commit

Permalink
Add 3.12 to CI (#3863)
Browse files Browse the repository at this point in the history
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: #3491 (comment)
  • Loading branch information
rodrigogiraoserrao authored Dec 14, 2023
1 parent 4a12076 commit e1b94e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -846,6 +847,7 @@ def setup_selection(pilot):
)


@pytest.mark.syntax
@pytest.mark.parametrize(
"theme_name", [theme.name for theme in TextAreaTheme.builtin_themes()]
)
Expand Down
6 changes: 2 additions & 4 deletions tests/text_area/test_languages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pytest

from textual.app import App, ComposeResult
Expand Down Expand Up @@ -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()

Expand All @@ -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():
Expand Down

0 comments on commit e1b94e4

Please sign in to comment.