Skip to content

Commit 82f874a

Browse files
committed
Check fast-tests coverage
And speed up CI by splitting the work further
1 parent 466c013 commit 82f874a

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

.github/workflows/ci.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,29 @@ jobs:
3838
run: python -m pip install --upgrade pip setuptools tox
3939
- name: Run tests
4040
# Disable coverage on PyPy
41-
run: python -m tox --recreate -e test $(${{ startsWith(matrix.python-version, 'pypy') }} && echo '-- -n auto --no-cov')
41+
run: |
42+
python -m tox --recreate -e test \
43+
-- -n auto --durations=10 -k "not test_can_generate_for_real_large_schema" \
44+
$(${{ startsWith(matrix.python-version, 'pypy') }} && echo '--no-cov')
45+
46+
test-slow:
47+
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8"]
51+
fail-fast: false
52+
steps:
53+
- uses: actions/checkout@v2
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
- name: Install dependencies
59+
run: python -m pip install --upgrade pip setuptools tox
60+
- name: Run slow tests
61+
run: |
62+
python -m tox --recreate -e test \
63+
-- -n auto --durations=10 --no-cov -k test_can_generate_for_real_large_schema
4264
4365
release:
4466
runs-on: ubuntu-latest

src/hypothesis_jsonschema/_from_schema.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ def __from_schema(
155155
return st.nothing()
156156
if schema == TRUTHY:
157157
return JSON_STRATEGY
158+
assert isinstance(schema, dict)
159+
if schema.get("$schema") == "http://json-schema.org/draft-03/schema#":
160+
raise InvalidArgument("Draft-03 schemas are not supported")
158161
# Only check if declared, lest we error on inner non-latest-draft schemata.
159162
if "$schema" in schema:
160163
jsonschema.validators.validator_for(schema).check_schema(schema)
161-
if schema["$schema"] == "http://json-schema.org/draft-03/schema#":
162-
raise InvalidArgument("Draft-03 schemas are not supported")
163164

164-
assert isinstance(schema, dict)
165165
# Now we handle as many validation keywords as we can...
166166
# Applying subschemata with boolean logic
167167
if "not" in schema:

tests/test_canonicalise.py

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def test_canonicalises_to_empty(schema):
157157
({"type": "integer", "multipleOf": 1 / 32}, {"type": "integer"}),
158158
({"type": "number", "multipleOf": 1.0}, {"type": "integer"}),
159159
({"type": "number", "multipleOf": -3.0}, {"type": "integer", "multipleOf": 3}),
160+
(
161+
{"type": "number", "multipleOf": 0.75, "not": {"multipleOf": 1.25}},
162+
{"type": "number", "multipleOf": 0.75, "not": {"multipleOf": 1.25}},
163+
),
160164
(
161165
{"type": "array", "items": [True, False, True]},
162166
{"type": "array", "items": [{}], "maxItems": 1},

tests/test_from_schema.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,8 @@ def to_name_params(corpus):
205205
continue
206206
if n in UNSUPPORTED_SCHEMAS:
207207
continue
208-
elif n in SLOW_SCHEMAS:
208+
elif n in SLOW_SCHEMAS | FLAKY_SCHEMAS:
209209
yield pytest.param(n, marks=pytest.mark.skip)
210-
elif n in FLAKY_SCHEMAS:
211-
yield pytest.param(n, marks=pytest.mark.xfail(strict=False))
212210
else:
213211
if isinstance(corpus[n], dict) and "$schema" in corpus[n]:
214212
jsonschema.validators.validator_for(corpus[n]).check_schema(corpus[n])

0 commit comments

Comments
 (0)