Closed Bobronium closed 3 years ago
Let pytest rewrite assertion and hide unneeded traceback
_________________________________________________ test_1 _________________________________________________ snapshot = <perseus.pytest_plugin.PyTestSnapshotTest object at 0x110e6e090> def test_1(snapshot): > snapshot.assert_match('test sstring') tests/test_snapshot.py:2: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ perseus/pytest_plugin.py:65: in assert_match self.assert_value_matches_snapshot(value, prev_snapshot) perseus/_vendor/snapshottest/module.py:230: in assert_value_matches_snapshot formatter.assert_value_matches_snapshot(self, test_value, snapshot_value, Formatter()) perseus/_vendor/snapshottest/formatters.py:20: in assert_value_matches_snapshot test.assert_equals(formatter.normalize(test_value), snapshot_value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <perseus.pytest_plugin.PyTestSnapshotTest object at 0x110e6e090>, value = 'test sstring' snapshot = 'test string' def assert_equals(self, value, snapshot): > assert value == snapshot E AssertionError perseus/_vendor/snapshottest/module.py:233: AssertionError ======================================== short test summary info ========================================= FAILED tests/test_snapshot.py::test_1 - AssertionError =========================================== 1 failed in 0.74s ============================================
___________________________________________ test_1 ____________________________________________ snapshot = <perseus.pytest_plugin.PyTestSnapshotTest object at 0x10baa5110> def test_1(snapshot): > snapshot.assert_match('test sstring') E AssertionError: assert 'test sstring' == 'test string' E - test string E + test sstring E ? + tests/test_snapshot.py:2: AssertionError =================================== short test summary info =================================== FAILED tests/test_snapshot.py::test_1 - AssertionError: assert 'test sstring' == 'test string' ====================================== 1 failed in 1.25s ======================================
Thank you, It's a good start for the most useful library 🌚
Let pytest rewrite assertion and hide unneeded traceback
Before:
After: