Skip to content

Commit 3e59f7b

Browse files
ShaharNavehjreback
authored andcommitted
TST: parametrize tests (#31228)
1 parent 339edcd commit 3e59f7b

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

pandas/tests/computation/test_eval.py

+24-30
Original file line numberDiff line numberDiff line change
@@ -573,45 +573,39 @@ def test_series_negate(self):
573573
result = pd.eval(expr, engine=self.engine, parser=self.parser)
574574
tm.assert_series_equal(expect, result)
575575

576-
def test_frame_pos(self):
576+
@pytest.mark.parametrize(
577+
"lhs",
578+
[
579+
# Float
580+
DataFrame(randn(5, 2)),
581+
# Int
582+
DataFrame(randint(5, size=(5, 2))),
583+
# bool doesn't work with numexpr but works elsewhere
584+
DataFrame(rand(5, 2) > 0.5),
585+
],
586+
)
587+
def test_frame_pos(self, lhs):
577588
expr = self.ex("+")
578-
579-
# float
580-
lhs = DataFrame(randn(5, 2))
581589
expect = lhs
582-
result = pd.eval(expr, engine=self.engine, parser=self.parser)
583-
tm.assert_frame_equal(expect, result)
584590

585-
# int
586-
lhs = DataFrame(randint(5, size=(5, 2)))
587-
expect = lhs
588-
result = pd.eval(expr, engine=self.engine, parser=self.parser)
589-
tm.assert_frame_equal(expect, result)
590-
591-
# bool doesn't work with numexpr but works elsewhere
592-
lhs = DataFrame(rand(5, 2) > 0.5)
593-
expect = lhs
594591
result = pd.eval(expr, engine=self.engine, parser=self.parser)
595592
tm.assert_frame_equal(expect, result)
596593

597-
def test_series_pos(self):
594+
@pytest.mark.parametrize(
595+
"lhs",
596+
[
597+
# Float
598+
Series(randn(5)),
599+
# Int
600+
Series(randint(5, size=5)),
601+
# bool doesn't work with numexpr but works elsewhere
602+
Series(rand(5) > 0.5),
603+
],
604+
)
605+
def test_series_pos(self, lhs):
598606
expr = self.ex("+")
599-
600-
# float
601-
lhs = Series(randn(5))
602-
expect = lhs
603-
result = pd.eval(expr, engine=self.engine, parser=self.parser)
604-
tm.assert_series_equal(expect, result)
605-
606-
# int
607-
lhs = Series(randint(5, size=5))
608607
expect = lhs
609-
result = pd.eval(expr, engine=self.engine, parser=self.parser)
610-
tm.assert_series_equal(expect, result)
611608

612-
# bool doesn't work with numexpr but works elsewhere
613-
lhs = Series(rand(5) > 0.5)
614-
expect = lhs
615609
result = pd.eval(expr, engine=self.engine, parser=self.parser)
616610
tm.assert_series_equal(expect, result)
617611

0 commit comments

Comments
 (0)