Skip to content

Commit

Permalink
Run tests in multiple shards and all Python versions (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Jun 29, 2023
1 parent 5f0e8bc commit 567aec4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -45,7 +46,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
shard: [0, 1, 2, 3]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Setup system dependencies
Expand All @@ -61,14 +64,16 @@ jobs:
pip install -U pip setuptools wheel
pip install -r ./requirements.txt
# Must match `shard` definition in the test matrix:
- name: Run tests
run: PYTHONPATH='.' pytest
run: PYTHONPATH='.' pytest --num-shards=4 --shard-id=${{ matrix.shard }}

stubtest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Setup system dependencies
Expand All @@ -90,6 +95,7 @@ jobs:
matrix-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
django-version: ['3.2', '4.2']
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Dev tools:
black==23.3.0
pre-commit==3.3.3
pytest==7.4.0
pytest-mypy-plugins==2.0.0
pytest-shard==0.1.2

# Django deps:
psycopg2-binary
Django==4.2.2
-e ./django_stubs_ext
Expand Down
4 changes: 2 additions & 2 deletions tests/typecheck/core/test_checks.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
- case: test_checks_register
main: |
from typing import Any, Sequence, Optional, Union
from typing import Any, Sequence, Optional, Union, List
from django.apps.config import AppConfig
from django.core.checks import register, Warning, CheckMessage
@register("foo", deploy=True)
def check_foo(app_configs: Union[Sequence[AppConfig], None], databases: Optional[Sequence[str]], **kwargs: Any) -> list[Warning]:
def check_foo(app_configs: Union[Sequence[AppConfig], None], databases: Optional[Sequence[str]], **kwargs: Any) -> List[Warning]:
if databases and 'databass' in databases:
return [Warning("Naughty list")]
return []
Expand Down
15 changes: 11 additions & 4 deletions tests/typecheck/db/models/test_query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,32 @@
pass
out: |
main:4: error: Type argument "int" of "ModelIterable" must be a subtype of "Model"
- case: django_db_models_query_module_has_ValuesListIterable
main: |
from typing import Tuple
from django.db.models.query import ValuesListIterable
class IntValuesListIterable(ValuesListIterable[tuple[int,int]]):
class IntValuesListIterable(ValuesListIterable[Tuple[int,int]]):
pass
class StringsValuesListIterable(ValuesListIterable[tuple[str,str,str]]):
class StringsValuesListIterable(ValuesListIterable[Tuple[str,str,str]]):
pass
class MultiTypeValuesListIterable(ValuesListIterable[tuple[str,int,float]]):
class MultiTypeValuesListIterable(ValuesListIterable[Tuple[str,int,float]]):
pass
class NonTupleValuesListIterable(ValuesListIterable[int]):
pass
out: |
main:10: error: Type argument "int" of "ValuesListIterable" must be a subtype of "Tuple[Any, ...]"
main:11: error: Type argument "int" of "ValuesListIterable" must be a subtype of "Tuple[Any, ...]"
- case: django_db_models_query_module_has_NamedValuesListIterable
main: |
from django.db.models.query import NamedValuesListIterable
out: |
- case: QuerySet_has__iterable_class_defined
main: |
from django.db.models.query import QuerySet, ValuesIterable, ModelIterable
Expand Down

0 comments on commit 567aec4

Please sign in to comment.