Skip to content

Commit 18bd5f4

Browse files
author
MarcoGorelli
committed
add check
1 parent fabdd5d commit 18bd5f4

File tree

14 files changed

+227
-55
lines changed

14 files changed

+227
-55
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,13 @@ repos:
333333
additional_dependencies:
334334
- autotyping==22.9.0
335335
- libcst==0.4.7
336+
- id: check-test-naming
337+
name: test names should start with 'test'
338+
entry: python -m scripts.check_test_naming
339+
types: [python]
340+
files: ^pandas/tests
341+
language: python
342+
exclude: |
343+
(?x)
344+
^pandas/tests/generic/test_generic.py # 50380
345+
|^pandas/tests/io/json/test_readlines.py # 50378

pandas/tests/computation/test_eval.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,6 @@ def test_pow(self, lhs, rhs, engine, parser):
353353
expected = _eval_single_bin(middle, "**", rhs, engine)
354354
tm.assert_almost_equal(result, expected)
355355

356-
def check_single_invert_op(self, lhs, engine, parser):
357-
# simple
358-
try:
359-
elb = lhs.astype(bool)
360-
except AttributeError:
361-
elb = np.array([bool(lhs)])
362-
expected = ~elb
363-
result = pd.eval("~elb", engine=engine, parser=parser)
364-
tm.assert_almost_equal(expected, result)
365-
366356
def test_frame_invert(self, engine, parser):
367357
expr = "~lhs"
368358

pandas/tests/frame/methods/test_to_timestamp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_to_timestamp_columns(self):
121121
assert result1.columns.freqstr == "AS-JAN"
122122
assert result2.columns.freqstr == "AS-JAN"
123123

124-
def to_timestamp_invalid_axis(self):
124+
def test_to_timestamp_invalid_axis(self):
125125
index = period_range(freq="A", start="1/1/2001", end="12/1/2009")
126126
obj = DataFrame(np.random.randn(len(index), 5), index=index)
127127

pandas/tests/internals/test_internals.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,10 +1323,6 @@ def test_period_can_hold_element(self, element):
13231323
elem = element(dti)
13241324
self.check_series_setitem(elem, pi, False)
13251325

1326-
def check_setting(self, elem, index: Index, inplace: bool):
1327-
self.check_series_setitem(elem, index, inplace)
1328-
self.check_frame_setitem(elem, index, inplace)
1329-
13301326
def check_can_hold_element(self, obj, elem, inplace: bool):
13311327
blk = obj._mgr.blocks[0]
13321328
if inplace:
@@ -1350,23 +1346,6 @@ def check_series_setitem(self, elem, index: Index, inplace: bool):
13501346
else:
13511347
assert ser.dtype == object
13521348

1353-
def check_frame_setitem(self, elem, index: Index, inplace: bool):
1354-
arr = index._data.copy()
1355-
df = DataFrame(arr)
1356-
1357-
self.check_can_hold_element(df, elem, inplace)
1358-
1359-
if is_scalar(elem):
1360-
df.iloc[0, 0] = elem
1361-
else:
1362-
df.iloc[: len(elem), 0] = elem
1363-
1364-
if inplace:
1365-
# assertion here implies setting was done inplace
1366-
assert df._mgr.arrays[0] is arr
1367-
else:
1368-
assert df.dtypes[0] == object
1369-
13701349

13711350
class TestShouldStore:
13721351
def test_should_store_categorical(self):

pandas/tests/io/formats/test_format.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import itertools
1212
import locale
1313
from operator import methodcaller
14-
import os
1514
from pathlib import Path
1615
import re
1716
from shutil import get_terminal_size
@@ -106,11 +105,6 @@ def _assert_filepath_or_buffer_equals(expected):
106105
return _assert_filepath_or_buffer_equals
107106

108107

109-
def curpath():
110-
pth, _ = os.path.split(os.path.abspath(__file__))
111-
return pth
112-
113-
114108
def has_info_repr(df):
115109
r = repr(df)
116110
c1 = r.split("\n")[0].startswith("<class")

pandas/tests/io/test_feather.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_read_columns(self):
113113
columns = ["col1", "col3"]
114114
self.check_round_trip(df, expected=df[columns], columns=columns)
115115

116-
def read_columns_different_order(self):
116+
def test_read_columns_different_order(self):
117117
# GH 33878
118118
df = pd.DataFrame({"A": [1, 2], "B": ["x", "y"], "C": [True, False]})
119119
self.check_round_trip(df, columns=["B", "A"])

pandas/tests/series/methods/test_explode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_invert_array():
7676
@pytest.mark.parametrize(
7777
"s", [pd.Series([1, 2, 3]), pd.Series(pd.date_range("2019", periods=3, tz="UTC"))]
7878
)
79-
def non_object_dtype(s):
79+
def test_non_object_dtype(s):
8080
result = s.explode()
8181
tm.assert_series_equal(result, s)
8282

pandas/tests/strings/test_cat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
_testing as tm,
1212
concat,
1313
)
14-
from pandas.tests.strings.test_strings import assert_series_or_index_equal
14+
15+
16+
def assert_series_or_index_equal(left, right):
17+
if isinstance(left, Series):
18+
tm.assert_series_equal(left, right)
19+
else: # Index
20+
tm.assert_index_equal(left, right)
1521

1622

1723
@pytest.mark.parametrize("other", [None, Series, Index])

pandas/tests/strings/test_strings.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ def test_startswith_endswith_non_str_patterns(pattern):
2626
ser.str.endswith(pattern)
2727

2828

29-
def assert_series_or_index_equal(left, right):
30-
if isinstance(left, Series):
31-
tm.assert_series_equal(left, right)
32-
else: # Index
33-
tm.assert_index_equal(left, right)
34-
35-
3629
# test integer/float dtypes (inferred by constructor) and mixed
3730

3831

pandas/tests/tseries/offsets/test_dst.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@
3030
YearEnd,
3131
)
3232

33-
from pandas.tests.tseries.offsets.test_offsets import get_utc_offset_hours
3433
from pandas.util.version import Version
3534

3635
# error: Module has no attribute "__version__"
3736
pytz_version = Version(pytz.__version__) # type: ignore[attr-defined]
3837

3938

39+
def get_utc_offset_hours(ts):
40+
# take a Timestamp and compute total hours of utc offset
41+
o = ts.utcoffset()
42+
return (o.days * 24 * 3600 + o.seconds) / 3600.0
43+
44+
4045
class TestDST:
4146

4247
# one microsecond before the DST transition

0 commit comments

Comments
 (0)