Skip to content

Commit c00977a

Browse files
author
regmibijay
committed
parametrized test, removed unnecessary description
1 parent 561d83e commit c00977a

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
import pytest
2-
import pandas as pd
31
from datetime import datetime as dt
2+
43
import numpy as np
4+
import pytest
55

6-
"""targeting #GH40781"""
6+
from pandas import DataFrame
77

8-
# arbitrary df to test
9-
df = pd.DataFrame(
10-
{
11-
"A" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
12-
"B": [dt.now() for i in range(0, 10)]
13-
}
14-
)
158

16-
17-
def test_axis_lim_invalid():
18-
global df
19-
"""
20-
supplying ranges with str, datetime and
21-
mixed int,str and float,str dtype to raise
22-
ValueError. Valid dtypes are np.datetime64
23-
int, and float.
24-
"""
25-
lim = [
26-
["1", "3"],
27-
[dt.now(), dt.now()],
28-
[1, "2"],
29-
[0.1, "0.2"],
30-
[np.datetime64(dt.now()), dt.now()]
31-
]
9+
@pytest.mark.parametrize("df, lim", [
10+
(
11+
DataFrame(
12+
{
13+
"A" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
14+
"B": [dt.now() for i in range(0, 10)]
15+
}
16+
),
17+
[
18+
["1", "3"],
19+
[dt.now(), dt.now()],
20+
[1, "2"],
21+
[0.1, "0.2"],
22+
[np.datetime64(dt.now()), dt.now()]
23+
]
24+
)
25+
]
26+
)
27+
def test_axis_lim_invalid(df, lim):
3228
for elem in lim:
3329
with pytest.raises(ValueError, match="`xlim` contains values"):
3430
df.plot.line(x="A", xlim=elem)
3531

3632

37-
def test_axis_lim_valid():
38-
global df
39-
"""
40-
supplying ranges with
41-
valid dtypes: np.datetime64
42-
int, and float, this test
43-
should not raise errors.
44-
"""
45-
lim = [
46-
[1, 3],
47-
[np.datetime64(dt.now()), np.datetime64(dt.now())],
48-
[0.1, 0.2],
49-
]
33+
@pytest.mark.parametrize("df, lim", [
34+
(
35+
DataFrame(
36+
{
37+
"A" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
38+
"B": [dt.now() for i in range(0, 10)]
39+
}
40+
),
41+
[
42+
[1, 3],
43+
[0.1, 0.2],
44+
[np.datetime64(dt.now()), np.datetime64(dt.now())]
45+
]
46+
)
47+
]
48+
)
49+
def test_axis_lim_valid(df, lim):
5050
for elem in lim:
51-
df.plot.line(x="A", ylim=elem)
51+
df.plot.line(x="A", xlim=elem)

0 commit comments

Comments
 (0)