@@ -320,6 +320,21 @@ def test_operations(self):
320320 assert 3 * bag_1 == self .bag_type ('bcc' * 3 )
321321 assert 3 * bag_2 == self .bag_type ('cddddd' * 3 )
322322
323+ # We only allow floor division on bags, not regular divison, because a
324+ # decimal bag is unheard of.
325+ with cute_testing .RaiseAssertor (TypeError ):
326+ bag_0 / 2
327+ with cute_testing .RaiseAssertor (TypeError ):
328+ bag_1 / 2
329+ with cute_testing .RaiseAssertor (TypeError ):
330+ bag_2 / 2
331+ with cute_testing .RaiseAssertor (TypeError ):
332+ bag_0 / self .bag_type ('ab' )
333+ with cute_testing .RaiseAssertor (TypeError ):
334+ bag_1 / self .bag_type ('ab' )
335+ with cute_testing .RaiseAssertor (TypeError ):
336+ bag_2 / self .bag_type ('ab' )
337+
323338 assert bag_0 // 2 == self .bag_type ('bc' )
324339 assert bag_1 // 2 == self .bag_type ('c' )
325340 assert bag_2 // 2 == self .bag_type ('dd' )
@@ -438,6 +453,12 @@ def test_mutating(self):
438453 assert bag == self .bag_type ('abracadabra' + 'a' * 5 )
439454 assert bag is bag_reference
440455
456+ # We only allow floor division on bags, not regular divison, because a
457+ # decimal bag is unheard of.
458+ bag = bag_reference = self .bag_type ('abracadabra' )
459+ with cute_testing .RaiseAssertor (TypeError ):
460+ bag ['a' ] /= 2
461+
441462 bag = bag_reference = self .bag_type ('abracadabra' )
442463 bag ['a' ] //= 2
443464 assert bag == self .bag_type ('abracdbr' )
@@ -604,6 +625,8 @@ def test_mutating(self):
604625 bag ['a' ] -= 1
605626 with cute_testing .RaiseAssertor (TypeError ):
606627 bag ['a' ] *= 2
628+ with cute_testing .RaiseAssertor (TypeError ):
629+ bag ['a' ] /= 2
607630 with cute_testing .RaiseAssertor (TypeError ):
608631 bag ['a' ] //= 2
609632 with cute_testing .RaiseAssertor (TypeError ):
@@ -637,6 +660,12 @@ def test_mutating(self):
637660 assert bag == bag_reference + bag_reference + bag_reference
638661 assert bag is not bag_reference
639662
663+ # We only allow floor division on bags, not regular divison, because a
664+ # decimal bag is unheard of.
665+ bag = bag_reference
666+ with cute_testing .RaiseAssertor (TypeError ):
667+ bag ['a' ] /= 2
668+
640669 bag = bag_reference
641670 bag //= 3
642671 assert bag == self .bag_type ('a' )
0 commit comments