Skip to content

Commit 1ff40d6

Browse files
YikunHyukjinKwon
authored andcommitted
[SPARK-37886][PYTHON][TESTS] Use ComparisonTestBase as base class in OpsTestBase
### What changes were proposed in this pull request? - Rename TestCasesUtils to OpsTestBase - Make OpsTestCase inherited from `ComparisonTestBase`(`PandasOnSparkTestCase` with `pdf` and `psdf`) - Make `*OpsTest` inherited from `OpsTestBase` ### Why are the changes needed? All data type ops related tests case are using `PandasOnSparkTestCase, TestCasesUtils` as basic classes, we'd better just let `TestCasesUtils` inherited from `PandasOnSparkTestCase` instead of multiple inheritance. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT Closes #35203 from Yikun/opstest_refactor. Authored-by: Yikun Jiang <yikunkero@gmail.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent b4f0b18 commit 1ff40d6

File tree

12 files changed

+30
-43
lines changed

12 files changed

+30
-43
lines changed

python/pyspark/pandas/tests/data_type_ops/test_binary_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
from pandas.api.types import CategoricalDtype
2020

2121
from pyspark import pandas as ps
22-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
23-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
22+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2423

2524

26-
class BinaryOpsTest(PandasOnSparkTestCase, TestCasesUtils):
25+
class BinaryOpsTest(OpsTestBase):
2726
@property
2827
def pser(self):
2928
return pd.Series([b"1", b"2", b"3"])

python/pyspark/pandas/tests/data_type_ops/test_boolean_ops.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525

2626
from pyspark import pandas as ps
2727
from pyspark.pandas import option_context
28-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
28+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2929
from pyspark.pandas.typedef.typehints import (
3030
extension_float_dtypes_available,
3131
extension_object_dtypes_available,
3232
)
33-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
3433

3534

36-
class BooleanOpsTest(PandasOnSparkTestCase, TestCasesUtils):
35+
class BooleanOpsTest(OpsTestBase):
3736
@property
3837
def bool_pdf(self):
3938
return pd.DataFrame({"this": [True, False, True], "that": [False, True, True]})
@@ -381,7 +380,7 @@ def test_ge(self):
381380
@unittest.skipIf(
382381
not extension_object_dtypes_available, "pandas extension object dtypes are not available"
383382
)
384-
class BooleanExtensionOpsTest(PandasOnSparkTestCase, TestCasesUtils):
383+
class BooleanExtensionOpsTest(OpsTestBase):
385384
@property
386385
def boolean_pdf(self):
387386
return pd.DataFrame(

python/pyspark/pandas/tests/data_type_ops/test_categorical_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323

2424
from pyspark import pandas as ps
2525
from pyspark.pandas.config import option_context
26-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
27-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
26+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2827

2928

30-
class CategoricalOpsTest(PandasOnSparkTestCase, TestCasesUtils):
29+
class CategoricalOpsTest(OpsTestBase):
3130
@property
3231
def pdf(self):
3332
return pd.DataFrame(

python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
import pandas as pd
2222

2323
from pyspark import pandas as ps
24-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
25-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
24+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2625

2726

28-
class ComplexOpsTest(PandasOnSparkTestCase, TestCasesUtils):
27+
class ComplexOpsTest(OpsTestBase):
2928
@property
3029
def pser(self):
3130
return pd.Series([[1, 2, 3]])

python/pyspark/pandas/tests/data_type_ops/test_date_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
from pandas.api.types import CategoricalDtype
2222

2323
from pyspark import pandas as ps
24-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
25-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
24+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2625

2726

28-
class DateOpsTest(PandasOnSparkTestCase, TestCasesUtils):
27+
class DateOpsTest(OpsTestBase):
2928
@property
3029
def pser(self):
3130
return pd.Series(

python/pyspark/pandas/tests/data_type_ops/test_datetime_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
from pandas.api.types import CategoricalDtype
2222

2323
from pyspark import pandas as ps
24-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
25-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
24+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2625

2726

28-
class DatetimeOpsTest(PandasOnSparkTestCase, TestCasesUtils):
27+
class DatetimeOpsTest(OpsTestBase):
2928
@property
3029
def pser(self):
3130
return pd.Series(pd.date_range("1994-1-31 10:30:15", periods=3, freq="D"))

python/pyspark/pandas/tests/data_type_ops/test_null_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
from pandas.api.types import CategoricalDtype
2020

2121
import pyspark.pandas as ps
22-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
23-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
22+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2423

2524

26-
class NullOpsTest(PandasOnSparkTestCase, TestCasesUtils):
25+
class NullOpsTest(OpsTestBase):
2726
@property
2827
def pser(self):
2928
return pd.Series([None, None, None])

python/pyspark/pandas/tests/data_type_ops/test_num_ops.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@
2525

2626
from pyspark import pandas as ps
2727
from pyspark.pandas.config import option_context
28-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
28+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2929
from pyspark.pandas.typedef.typehints import (
3030
extension_dtypes_available,
3131
extension_float_dtypes_available,
3232
extension_object_dtypes_available,
3333
)
3434
from pyspark.sql.types import DecimalType, IntegralType
35-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
3635

3736

38-
class NumOpsTest(PandasOnSparkTestCase, TestCasesUtils):
37+
class NumOpsTest(OpsTestBase):
3938
"""Unit tests for arithmetic operations of numeric data types.
4039
4140
A few test cases are disabled because pandas-on-Spark returns float64 whereas pandas
@@ -450,7 +449,7 @@ def test_ge(self):
450449

451450

452451
@unittest.skipIf(not extension_dtypes_available, "pandas extension dtypes are not available")
453-
class IntegralExtensionOpsTest(PandasOnSparkTestCase, TestCasesUtils):
452+
class IntegralExtensionOpsTest(OpsTestBase):
454453
@property
455454
def intergral_extension_psers(self):
456455
return [pd.Series([1, 2, 3, None], dtype=dtype) for dtype in self.integral_extension_dtypes]
@@ -590,7 +589,7 @@ def test_rxor(self):
590589
@unittest.skipIf(
591590
not extension_float_dtypes_available, "pandas extension float dtypes are not available"
592591
)
593-
class FractionalExtensionOpsTest(PandasOnSparkTestCase, TestCasesUtils):
592+
class FractionalExtensionOpsTest(OpsTestBase):
594593
@property
595594
def fractional_extension_psers(self):
596595
return [

python/pyspark/pandas/tests/data_type_ops/test_string_ops.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323

2424
from pyspark import pandas as ps
2525
from pyspark.pandas.config import option_context
26-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
26+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2727
from pyspark.pandas.typedef.typehints import extension_object_dtypes_available
28-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
2928

3029
if extension_object_dtypes_available:
3130
from pandas import StringDtype
3231

3332

34-
class StringOpsTest(PandasOnSparkTestCase, TestCasesUtils):
33+
class StringOpsTest(OpsTestBase):
3534
@property
3635
def bool_pdf(self):
3736
return pd.DataFrame({"this": ["x", "y", "z"], "that": ["z", "y", "x"]})
@@ -237,7 +236,7 @@ def test_ge(self):
237236
@unittest.skipIf(
238237
not extension_object_dtypes_available, "pandas extension object dtypes are not available"
239238
)
240-
class StringExtensionOpsTest(StringOpsTest, PandasOnSparkTestCase, TestCasesUtils):
239+
class StringExtensionOpsTest(StringOpsTest):
241240
@property
242241
def pser(self):
243242
return pd.Series(["x", "y", "z", None], dtype="string")

python/pyspark/pandas/tests/data_type_ops/test_timedelta_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
from pandas.api.types import CategoricalDtype
2222

2323
import pyspark.pandas as ps
24-
from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
25-
from pyspark.testing.pandasutils import PandasOnSparkTestCase
24+
from pyspark.pandas.tests.data_type_ops.testing_utils import OpsTestBase
2625

2726

28-
class TimedeltaOpsTest(PandasOnSparkTestCase, TestCasesUtils):
27+
class TimedeltaOpsTest(OpsTestBase):
2928
@property
3029
def pser(self):
3130
return pd.Series([timedelta(1), timedelta(microseconds=2), timedelta(weeks=3)])

0 commit comments

Comments
 (0)