Skip to content

Commit 162b0c6

Browse files
committed
Refactor tests
1 parent 9badf37 commit 162b0c6

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

Orange/widgets/data/tests/test_owdatasampler.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,26 @@ def select_sampling_type(self, sampling_type):
6161
buttons = self.widget.controls.sampling_type.group.buttons()
6262
buttons[sampling_type].click()
6363

64-
def test_outputs(self):
64+
def test_no_intersection_in_outputs(self):
6565
""" Check whether outputs intersect and whether length of outputs sums
6666
to length of original data """
6767
self.send_signal("Data", self.zoo)
68-
self._output_test_helper()
69-
self.widget.cb_seed.setChecked(True)
70-
self._output_test_helper()
71-
self.widget.cb_stratify.setChecked(True)
72-
self._output_test_helper()
68+
w = self.widget
69+
sampling_types = [w.FixedProportion, w.FixedSize, w.CrossValidation]
7370

74-
def _output_test_helper(self):
75-
types = [self.widget.FixedProportion, self.widget.FixedSize,
76-
self.widget.CrossValidation]
77-
for t in types:
78-
self.select_sampling_type(t)
79-
self.widget.commit()
80-
sample = self.get_output("Data Sample")
81-
other = self.get_output("Remaining Data")
82-
self.assertEqual(len(self.zoo), len(sample) + len(other))
83-
self._check_intersection(sample, other)
71+
for replicable in [True, False]:
72+
for stratified in [True, False]:
73+
for sampling_type in sampling_types:
74+
self.widget.cb_seed.setChecked(replicable)
75+
self.widget.cb_stratify.setChecked(stratified)
76+
self.select_sampling_type(sampling_type)
77+
self.widget.commit()
8478

85-
def _check_intersection(self, sample, other):
79+
sample = self.get_output("Data Sample")
80+
other = self.get_output("Remaining Data")
81+
self.assertEqual(len(self.zoo), len(sample) + len(other))
82+
self.assertNoIntersection(sample, other)
83+
84+
def assertNoIntersection(self, sample, other):
8685
for inst in sample:
8786
self.assertNotIn(inst, other)

0 commit comments

Comments
 (0)