-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62e9e5f
commit 4869f4e
Showing
8 changed files
with
242 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from coola import objects_are_equal | ||
from tests.unit.equality.comparators.test_collection import ( | ||
COLLECTION_EQUAL, | ||
COLLECTION_NOT_EQUAL, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from tests.unit.equality.comparators.utils import ExamplePair | ||
|
||
|
||
@pytest.mark.parametrize("example", COLLECTION_EQUAL) | ||
@pytest.mark.parametrize("show_difference", [True, False]) | ||
def test_objects_are_equal_true( | ||
example: ExamplePair, show_difference: bool, caplog: pytest.LogCaptureFixture | ||
) -> None: | ||
with caplog.at_level(logging.INFO): | ||
assert objects_are_equal(example.object1, example.object2, show_difference) | ||
assert not caplog.messages | ||
|
||
|
||
@pytest.mark.parametrize("example", COLLECTION_NOT_EQUAL) | ||
def test_objects_are_equal_false(example: ExamplePair, caplog: pytest.LogCaptureFixture) -> None: | ||
with caplog.at_level(logging.INFO): | ||
assert not objects_are_equal(example.object1, example.object2) | ||
assert not caplog.messages | ||
|
||
|
||
@pytest.mark.parametrize("example", COLLECTION_NOT_EQUAL) | ||
def test_objects_are_equal_false_show_difference( | ||
example: ExamplePair, caplog: pytest.LogCaptureFixture | ||
) -> None: | ||
with caplog.at_level(logging.INFO): | ||
assert not objects_are_equal(example.object1, example.object2, show_difference=True) | ||
assert caplog.messages[-1].startswith(example.expected_message) |
Oops, something went wrong.