Skip to content

Commit 6667765

Browse files
committed
adjust to wider exception printing in Python3.13
1 parent 3761374 commit 6667765

File tree

7 files changed

+31
-26
lines changed

7 files changed

+31
-26
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ EXTRAS=[pycodegen]
2929
PYSOURCES=$(wildcard ${MODULE}/**.py ${MODULE}/avro/*.py ${MODULE}/tests/*.py) setup.py
3030
DEVPKGS=-rdev-requirements.txt -rtest-requirements.txt -rmypy-requirements.txt -rlint-requirements.txt
3131
COVBASE=coverage run --append
32-
PYTEST_EXTRA ?= -rs
32+
PYTEST_EXTRA ?=
3333

3434
VERSION=8.7.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
3535
--max-count=1 --format=format:%cI`)
@@ -155,7 +155,7 @@ diff-cover.html: coverage.xml
155155

156156
## test : run the schema-salad test suite
157157
test: $(PYSOURCES)
158-
python -m pytest -rs ${PYTEST_EXTRA}
158+
python -m pytest -rsfE ${PYTEST_EXTRA}
159159

160160
## testcov : run the schema-salad test suite and collect coverage
161161
testcov: $(PYSOURCES)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
from cachecontrol.caches.file_cache import SeparateBodyFileCache as SeparateBodyFileCache
1+
from cachecontrol.caches.file_cache import (
2+
SeparateBodyFileCache as SeparateBodyFileCache,
3+
)
24

35
__all__ = ["SeparateBodyFileCache"]

mypy-stubs/cachecontrol/caches/file_cache.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from cachecontrol.cache import SeparateBodyBaseCache
21
from datetime import datetime
3-
from filelock import BaseFileLock
42
from pathlib import Path
53
from typing import IO, ContextManager
64

5+
from cachecontrol.cache import SeparateBodyBaseCache
6+
from filelock import BaseFileLock
7+
78
class _LockClass:
89
path: str
910

schema_salad/dlang_codegen.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88

99
from . import _logger, schema
1010
from .codegen_base import CodeGenBase, TypeDef
11-
from .cpp_codegen import isArray, isEnumSchema, isMapSchema, isRecordSchema, isUnionSchema, pred
11+
from .cpp_codegen import (
12+
isArray,
13+
isEnumSchema,
14+
isMapSchema,
15+
isRecordSchema,
16+
isUnionSchema,
17+
pred,
18+
)
1219
from .exceptions import SchemaException
1320
from .schema import shortname
1421

schema_salad/tests/test_codegen_errors.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def test_error_message1(tmp_path: Path) -> None:
3030

3131
def test_error_message2(tmp_path: Path) -> None:
3232
t = "test_schema/test2.cwl"
33-
match = r"""^.*test2\.cwl:2:1:\s+Field\s+`class`\s+contains\s+undefined\s+reference\s+to
34-
\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""
33+
match = r"""^.*test2\.cwl:2:1:\s+Field\s+`class`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""
3534
path = get_data("tests/" + t)
3635
assert path
3736
with pytest.raises(ValidationException, match=match):
@@ -100,8 +99,7 @@ def test_error_message8(tmp_path: Path) -> None:
10099
.*test8\.cwl:9:3:\s+checking\s+object\s+`.*test8\.cwl#step1`
101100
\s+\*\s+missing\s+required\s+field\s+`run`
102101
.*test8\.cwl:10:5:\s+\*\s+the\s+`scatterMethod`\s+field\s+is\s+not\s+valid\s+because:
103-
\s+contains\s+undefined\s+reference\s+to
104-
\s+`file:///.*/tests/test_schema/abc`$"""
102+
\s+contains\s+undefined\s+reference\s+to\s+`file:///.*/tests/test_schema/abc`$"""
105103
path = get_data("tests/" + t)
106104
assert path
107105
with pytest.raises(ValidationException, match=match):
@@ -144,9 +142,7 @@ def test_error_message11(tmp_path: Path) -> None:
144142
.*test11\.cwl:8:1:\s+the\s+`steps`\s+field\s+is\s+not\s+valid\s+because:
145143
\s+array\s+item\s+is\s+invalid\s+because
146144
.*test11\.cwl:9:3:\s+checking\s+object\s+`.*test11\.cwl#step1`
147-
.*test11\.cwl:10:5:\s+the\s+`run`\s+field\s+is\s+not\s+valid\s+because:
148-
\s+contains\s+undefined\s+reference\s+to
149-
\s+`file:///.*/tests/test_schema/blub\.cwl`$"""
145+
.*test11\.cwl:10:5:\s+the\s+`run`\s+field\s+is\s+not\s+valid\s+because:\s+contains\s+undefined\s+reference\s+to\s+`file:///.*/tests/test_schema/blub\.cwl`$"""
150146
path = get_data("tests/" + t)
151147
assert path
152148
with pytest.raises(ValidationException, match=match):

schema_salad/tests/test_errors.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def test_error_message3() -> None:
100100
match = r"""
101101
^.+test3\.cwl:6:1: checking field\s+'outputs'
102102
.+test3\.cwl:7:3: checking object\s+'.+test3\.cwl#bar'
103-
\s+Field 'type'\s+references\s+unknown\s+identifier\s+'xstring',\s+tried
104-
\s+file://.+/tests/test_schema/test3\.cwl#xstring$"""[
103+
\s+Field 'type'\s+references\s+unknown\s+identifier\s+'xstring',\s+tried\s+file://.+/tests/test_schema/test3\.cwl#xstring$"""[ # noqa: B950
105104
1:
106105
]
107106
with pytest.raises(ValidationException, match=match):
@@ -153,15 +152,15 @@ def test_error_message7() -> None:
153152

154153
t = "test_schema/test7.cwl"
155154
match = (
156-
r"""^.+test7\.cwl:2:1:\s+Object\s+'.+test7\.cwl'\s+is\s+not valid because
157-
\s+tried 'Workflow'\s+but
155+
r"""^.+test7\.cwl:2:1:\s+Object\s+'.+test7\.cwl'\s+is\s+not\s+valid\s+because
156+
\s+tried\s+'Workflow'\s+but
158157
.+test7\.cwl:8:1:\s+the 'steps'\s+field\s+is\s+not\s+valid\s+because
159-
\s+tried array\s+of\s+<WorkflowStep>\s+but
158+
\s+tried\s+array\s+of\s+<WorkflowStep>\s+but
160159
.+test7\.cwl:9:3:\s+item is\s+invalid\s+because
161160
\s+\* missing\s+required\s+field\s+'run'
162-
.+test7\.cwl:10:5:\s+\* invalid\s+field\s+'scatter_method',\s+expected\s+one """
163-
+ r"""of:\s+'id',\s+'in', 'out',\s+'requirements',\s+'hints',\s+"""
164-
+ r"""'label',\s+'doc',\s+'run',\s+'scatter',\s+'scatterMethod'$"""
161+
.+test7\.cwl:10:5:\s+\* invalid\s+field\s+'scatter_method',\s+expected\s+one\s+"""
162+
+ r"of:\s+'id',\s+'in',\s+'out',\s+'requirements',\s+'hints',\s+"
163+
+ r"'label',\s+'doc',\s+'run',\s+'scatter',\s+'scatterMethod'$"
165164
)
166165
with pytest.raises(ValidationException, match=match):
167166
load_and_validate(document_loader, avsc_names, str(get_data("tests/" + t)), True)
@@ -254,17 +253,17 @@ def test_error_message15() -> None:
254253

255254
t = "test_schema/test15.cwl"
256255
match = (
257-
r"""^.+test15\.cwl:3:1:\s+Object\s+'.+test15\.cwl'\s+is not valid because
256+
r"""^.+test15\.cwl:3:1:\s+Object\s+'.+test15\.cwl'\s+is\s+not\s+valid\s+because
258257
\s+tried\s+'CommandLineTool'\s+but
259-
.+test15\.cwl:6:1:\s+the 'inputs'\s+field\s+is\s+not valid\s+because
260-
.+test15\.cwl:7:3:\s+item is\s+invalid\s+because
258+
.+test15\.cwl:6:1:\s+the\s+'inputs'\s+field\s+is\s+not\s+valid\s+because
259+
.+test15\.cwl:7:3:\s+item\s+is\s+invalid\s+because
261260
.+test15\.cwl:9:5:\s+the\s+'inputBinding'\s+field\s+is\s+not\s+valid\s+because
262261
.+tried\s+CommandLineBinding\s+but
263262
.+test15\.cwl:11:7: \*\s+invalid\s+field\s+'invalid_field',\s+expected\s+"""
264263
+ r"""one\s+of:\s+'loadContents',\s+'position',\s+'prefix',\s+'separate',"""
265264
+ r"""\s+'itemSeparator',\s+'valueFrom',\s+'shellQuote'
266265
.+test15\.cwl:12:7: \*\s+invalid\s+field\s+'another_invalid_field',"""
267-
+ r"""\s+expected one\s+of:\s+'loadContents',\s+'position',\s+'prefix',"""
266+
+ r"""\s+expected\s+one\s+of:\s+'loadContents',\s+'position',\s+'prefix',"""
268267
+ r"""\s+'separate',\s+'itemSeparator',\s+'valueFrom',\s+'shellQuote'$"""
269268
)
270269
with pytest.raises(ValidationException, match=match):

schema_salad/tests/test_print_oneline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_for_invalid_yaml2() -> None:
177177
assert (
178178
msg.endswith("expected <block end>, but found ':'")
179179
or msg.endswith("expected <block end>, but found u':'")
180-
or re.search(r"mapping with\s+implicit\s+null key$", msg, re.M)
180+
or re.search(r"mapping\s+with\s+implicit\s+null\s+key$", msg, re.M)
181181
)
182182
print("\n", e)
183183
raise

0 commit comments

Comments
 (0)