Skip to content

Commit 8a45321

Browse files
committed
Update test expectations.
1 parent 6328c78 commit 8a45321

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

tests/test_base_loader.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,12 @@ class CustomItemLoader(ItemLoader):
414414
name_in = MapCompose(float)
415415

416416
il = CustomItemLoader()
417-
with pytest.raises(ValueError, match="could not convert string to float"):
417+
with pytest.raises(
418+
ValueError,
419+
match="Error with input processor MapCompose: .* "
420+
"error='ValueError: Error in MapCompose .* "
421+
"error='ValueError: could not convert",
422+
):
418423
il.add_value("name", ["marta", "other"])
419424

420425
def test_error_output_processor(self):
@@ -423,14 +428,21 @@ class CustomItemLoader(ItemLoader):
423428

424429
il = CustomItemLoader()
425430
il.add_value("name", "marta")
426-
with pytest.raises(ValueError, match="could not convert string to float"):
431+
with pytest.raises(
432+
ValueError,
433+
match="Error with output processor: .* "
434+
"error='ValueError: Error in Compose .* "
435+
"error='ValueError: could not convert",
436+
):
427437
il.load_item()
428438

429439
def test_error_processor_as_argument(self):
430440
il = CustomItemLoader()
431441
with pytest.raises(
432442
ValueError,
433-
match=r"float\(\) argument must be a string or a real number, not 'list'",
443+
match=r"Error with processor Compose .* "
444+
r"error='ValueError: Error in Compose .* "
445+
r"error='TypeError: float\(\) argument",
434446
):
435447
il.add_value("name", ["marta", "other"], Compose(float))
436448

tests/test_processors.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ def test_compose():
2929
proc = Compose(str.upper)
3030
assert proc(None) is None
3131
proc = Compose(str.upper, stop_on_none=False)
32-
with pytest.raises(ValueError, match="doesn't apply to a 'NoneType' object"):
32+
with pytest.raises(
33+
ValueError,
34+
match="Error in Compose with .* error='TypeError: (descriptor 'upper'|'str' object expected)",
35+
):
3336
proc(None)
3437
proc = Compose(str.upper, lambda x: x + 1)
35-
with pytest.raises(ValueError, match="can only concatenate str"):
38+
with pytest.raises(
39+
ValueError,
40+
match="Error in Compose with .* error='TypeError: (can only|unsupported operand)",
41+
):
3642
proc("hello")
3743

3844

@@ -50,8 +56,14 @@ def filter_world(x):
5056
proc = MapCompose(filter_world, str.upper)
5157
assert proc(None) == []
5258
proc = MapCompose(filter_world, str.upper)
53-
with pytest.raises(ValueError, match="doesn't apply to a 'int' object"):
59+
with pytest.raises(
60+
ValueError,
61+
match="Error in MapCompose with .* error='TypeError: (descriptor 'upper'|'str' object expected)",
62+
):
5463
proc([1])
5564
proc = MapCompose(filter_world, lambda x: x + 1)
56-
with pytest.raises(ValueError, match="can only concatenate str"):
65+
with pytest.raises(
66+
ValueError,
67+
match="Error in MapCompose with .* error='TypeError: (can only|unsupported operand)",
68+
):
5769
proc("hello")

0 commit comments

Comments
 (0)