Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit 22513d7

Browse files
authored
Merge pull request #253 from snok/sondrelg/django-4
Update supported Django versions
2 parents d5decab + 340bfd2 commit 22513d7

File tree

6 files changed

+175
-140
lines changed

6 files changed

+175
-140
lines changed

.github/workflows/testing.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ jobs:
4040
fail-fast: false
4141
matrix:
4242
python-version: [ "3.7", "3.8" , "3.9", "3.10" ]
43-
django-version: [ "2.2", "3.0", "3.1", "3.2" ]
43+
django-version: [ "3.0", "3.1", "3.2", "4.0" ]
44+
exclude:
45+
# Django v4 drops Python 3.6, and 3.7 support
46+
- django-version: 4.0
47+
python-version: 3.7
4448
steps:
4549
- uses: actions/checkout@v2
4650
- uses: actions/setup-python@v2
@@ -50,17 +54,16 @@ jobs:
5054
id: poetry-cache
5155
with:
5256
path: ~/.local
53-
key: key-1
57+
key: key-3
5458
- name: Install poetry
5559
uses: snok/install-poetry@v1
5660
with:
57-
version: 1.2.0a2
5861
virtualenvs-create: false
5962
- uses: actions/cache@v2
6063
id: cache-venv
6164
with:
6265
path: .venv
63-
key: ${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-1
66+
key: ${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-2
6467
- run: |
6568
pip install virtualenv
6669
virtualenv .venv
@@ -72,23 +75,16 @@ jobs:
7275
run: |
7376
source .venv/bin/activate
7477
pip install "Django==${{ matrix.django-version }}"
75-
- run: |
76-
source .venv/bin/activate
77-
pip install coverage[toml]
78-
- name: Install DRF 3.11 on Django 2.2
79-
if: matrix.django-version == '2.2'
80-
run: pip install "djangorestframework==3.11.1"
8178
- name: Run tests
8279
run: |
8380
source .venv/bin/activate
84-
poetry run pytest --cov=. --cov-report=xml
85-
poetry run coverage report
81+
pytest --cov=. --cov-report xml --cov-report term-missing
8682
- name: Archive coverage
8783
uses: actions/upload-artifact@v2
8884
with:
8985
name: coverage-xml
9086
path: coverage.xml
91-
if: matrix.python-version == '3.10' && matrix.django-version == '3.2'
87+
if: matrix.python-version == '3.10' && matrix.django-version == '4.0'
9288
coverage:
9389
needs: test
9490
runs-on: ubuntu-latest

openapi_tester/schema_tester.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,19 @@ def get_response_schema_section(self, response: Response) -> dict[str, Any]:
170170

171171
def handle_one_of(self, schema_section: dict, data: Any, reference: str, **kwargs: Any):
172172
matches = 0
173+
passed_schema_section_formats = set()
173174
for option in schema_section["oneOf"]:
174175
try:
175176
self.test_schema_section(schema_section=option, data=data, reference=f"{reference}.oneOf", **kwargs)
176177
matches += 1
178+
passed_schema_section_formats.add(option.get("format"))
177179
except DocumentationError:
178180
continue
181+
if matches == 2 and passed_schema_section_formats == {"date", "date-time"}:
182+
# With Django v4, the datetime validator now parses normal
183+
# date formats successfully, so a oneOf: date // datetime section
184+
# will succeed twice where it used to succeed once.
185+
return
179186
if matches != 1:
180187
raise DocumentationError(f"{VALIDATE_ONE_OF_ERROR.format(matches=matches)}\n\nReference: {reference}.oneOf")
181188

0 commit comments

Comments
 (0)