Coverage for tests/test_pandas.py: 100%
20 statements
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-24 17:17 +0200
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-24 17:17 +0200
1from inline_snapshot import snapshot
2from inline_snapshot_pandas import assert_frame_equal
3from inline_snapshot_pandas import assert_index_equal
4from inline_snapshot_pandas import assert_series_equal
5from pandas import DataFrame
6from pandas import Index
7from pandas import Series
10def test_assert_equal():
11 df = DataFrame({"col0": [1, 2], "col1": [1, 5j], "col3": ["a", "b"]})
13 # the second argument can be a snapshot
14 assert_frame_equal(
15 df,
16 snapshot(
17 DataFrame(
18 [
19 {"col0": 1, "col1": (1 + 0j), "col3": "a"},
20 {"col0": 2, "col1": 5j, "col3": "b"},
21 ]
22 )
23 ),
24 )
26 # and can also be used without a snapshot
27 assert_frame_equal(df, df)
29 # for Index
30 index = Index(range(5))
31 assert_index_equal(index, snapshot(Index([0, 1, 2, 3, 4])))
33 # for Series
34 index = Series({1: 8, 5: 4})
35 assert_series_equal(index, snapshot(Series({1: 8, 5: 4})))
38def test_assert_equal_twice():
39 df = DataFrame({"col0": [1, 2], "col1": [1, 5j], "col3": ["a", "b"]})
41 s = snapshot(
42 DataFrame(
43 [
44 {"col0": 1, "col1": (1 + 0j), "col3": "a"},
45 {"col0": 2, "col1": 5j, "col3": "b"},
46 ]
47 )
48 )
50 assert_frame_equal(df, s)
52 assert_frame_equal(df, s)