Skip to content

Commit e647493

Browse files
committed
-
1 parent 2b9ea5d commit e647493

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

source_py3/test_python_toolbox/test_nifty_collections/test_bagging.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,23 @@ def test_operations(self):
318318
assert bag_1 // self.bag_type('ab') == 0
319319
assert bag_2 // self.bag_type('ab') == 0
320320

321-
assert bag_0 % 2 == self.bag_type('abcc')
322-
assert bag_1 % 2 == self.bag_type('bc')
323-
assert bag_2 % 2 == self.bag_type('cdd')
324-
assert bag_0 % 'ab' == self.bag_type('bccc')
325-
assert bag_1 % 'ab' == bag_1
326-
assert bag_2 % 'ab' == bag_2
321+
with cute_testing.RaiseAssertor(ZeroDivisionError):
322+
bag_0 // 0
323+
with cute_testing.RaiseAssertor(ZeroDivisionError):
324+
bag_0 // self.bag_type()
325+
326+
assert bag_0 % 2 == self.bag_type('ac') == bag_0 - ((bag_0 // 2) * 2) \
327+
== self.bag_type(OrderedDict((key, count % 2) for (key, count)
328+
in bag_0.items()))
329+
assert bag_1 % 2 == self.bag_type('b') == bag_1 - ((bag_1 // 2) * 2) \
330+
== self.bag_type(OrderedDict((key, count % 2) for (key, count)
331+
in bag_1.items()))
332+
assert bag_2 % 2 == self.bag_type('cd') == bag_2 - ((bag_2 // 2) * 2)\
333+
== self.bag_type(OrderedDict((key, count % 2) for (key, count)
334+
in bag_2.items()))
335+
assert bag_0 % self.bag_type('ac') == self.bag_type('bbcc')
336+
assert bag_1 % self.bag_type('b') == self.bag_type('cc')
337+
assert bag_2 % self.bag_type('cd') == self.bag_type('dddd')
327338

328339
assert bag_0 ** 2 == pow(bag_0, 2) == self.bag_type('abbbbccccccccc')
329340
assert bag_1 ** 2 == pow(bag_1, 2) == self.bag_type('bcccc')
@@ -344,9 +355,6 @@ def test_operations(self):
344355
(bag_2 // self.bag_type('cd'), bag_2 % self.bag_type('cd'))
345356

346357

347-
# blocktodo: continue for all operations
348-
349-
350358

351359

352360
class BaseMutableBagTestCase(BaseBagTestCase):

0 commit comments

Comments
 (0)