Skip to content

Commit

Permalink
fix IsOneOf example
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored and osintalex committed Mar 28, 2022
1 parent c7132cd commit 0a1334b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dirty_equals/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ def __init__(self, expected_value: Any, *more_expected_values: Any):
assert 1 == IsOneOf(1, 2, 3)
assert 4 != IsOneOf(1, 2, 3)
# check that a list either contain 1 or is empty
assert [1, 2, 3] == Contains(1) | IsOneOf([])
assert [] == Contains(1) | IsOneOf([])
```
"""
self.expected_values: Tuple[Any, ...] = (expected_value,) + more_expected_values
super().__init__(*self.expected_values)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def _import_execute(module_name: str, source: str, rewrite_assertions: bool = Fa

def extract_code_chunks(path: Path, text: str, offset: int):
rel_path = path.relative_to(ROOT_DIR)
fences = len(re.findall(r'^```', text, flags=re.M))
if fences % 2 != 0:
raise ValueError(
f'{rel_path}:{offset} has an odd number of code fences (```), might be missing a closing fence'
)

for m_code in re.finditer(r'^```(.*?)$\n(.*?)^```', text, flags=re.M | re.S):
prefix = m_code.group(1).lower()
if not prefix.startswith(('py', '{.py')) or 'test="false"' in prefix:
Expand Down

0 comments on commit 0a1334b

Please sign in to comment.