Skip to content

Commit 534e3c7

Browse files
committed
ANY: fix repr and add tests
1 parent f7cdd36 commit 534e3c7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pytest_test_utils/_any.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def __init__(self, expected_type: Type[object]) -> None:
66
self.expected_type: Type[object] = expected_type
77

88
def __repr__(self) -> str:
9-
return "Any({self.expected_type.__name__})"
9+
return f"ANY({self.expected_type.__name__})"
1010

1111
def __eq__(self, other: Any) -> bool:
1212
return isinstance(other, self.expected_type)

tests.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import os
22
from pathlib import Path
33

4-
from pytest_test_utils import TmpDir
4+
import pytest
5+
6+
from pytest_test_utils import ANY, TmpDir
7+
8+
9+
def test_any() -> None:
10+
assert ANY(str) == "5"
11+
assert ANY(str) != 5
12+
13+
with pytest.raises(AssertionError):
14+
assert ANY(int) != 5
15+
assert ANY(int) == 5
16+
assert repr(ANY(int)) == "ANY(int)"
517

618

719
def test_is_tmp_dir(tmp_dir: TmpDir) -> None:

0 commit comments

Comments
 (0)