forked from pandas-dev/pandas-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_testing.py
55 lines (46 loc) · 1.37 KB
/
test_testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import annotations
import os.path
import pandas as pd
from pandas._testing import ensure_clean
from pandas.testing import (
assert_frame_equal,
assert_series_equal,
)
from typing_extensions import assert_type
from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
)
def test_types_assert_series_equal() -> None:
s1 = pd.Series([0, 1, 1, 0])
s2 = pd.Series([0, 1, 1, 0])
assert_series_equal(left=s1, right=s2)
assert_series_equal(
s1,
s2,
check_freq=False,
check_categorical=True,
check_flags=True,
check_datetimelike_compat=True,
)
if TYPE_CHECKING_INVALID_USAGE:
assert_series_equal( # type: ignore[call-overload] # pyright: ignore[reportGeneralTypeIssues]
s1,
s2,
check_dtype=True,
check_less_precise=True,
check_names=True,
)
assert_series_equal(s1, s2, check_like=True)
# GH 417
assert_series_equal(s1, s2, check_index=False)
def test_assert_frame_equal():
df1 = pd.DataFrame({"x": [1, 2, 3]})
df2 = pd.DataFrame({"x": [1, 2, 3]})
# GH 56
assert_frame_equal(df1, df2, check_index_type=False)
def test_ensure_clean():
with ensure_clean() as path:
check(assert_type(path, str), str)
pd.DataFrame({"x": [1, 2, 3]}).to_csv(path)
assert not os.path.exists(path)