Skip to content

Commit 468d1f7

Browse files
committed
-
1 parent b2daeed commit 468d1f7

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

source_py2/test_python_toolbox/test_nifty_collections/test_bagging.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2009-2015 Ram Rachum.
22
# This program is distributed under the MIT license.
33

4+
from __future__ import division
5+
46
import re
57
import pickle
68
import abc
@@ -454,11 +456,9 @@ def test_mutating(self):
454456
assert bag == self.bag_type('abracadabra' + 'a' * 5)
455457
assert bag is bag_reference
456458

457-
# We only allow floor division on bags, not regular divison, because a
458-
# decimal bag is unheard of.
459459
bag = bag_reference = self.bag_type('abracadabra')
460460
with cute_testing.RaiseAssertor(TypeError):
461-
bag['a'] /= 2
461+
bag['a'] /= 2 # Won't work because `bag['a']` happens to be odd.
462462

463463
bag = bag_reference = self.bag_type('abracadabra')
464464
bag['a'] //= 2
@@ -500,6 +500,12 @@ def test_mutating(self):
500500
assert bag == self.bag_type('abracadabra' * 2)
501501
assert bag is bag_reference
502502

503+
# We only allow floor division on bags, not regular divison, because a
504+
# decimal bag is unheard of.
505+
bag = bag_reference = self.bag_type('abracadabra')
506+
with cute_testing.RaiseAssertor(TypeError):
507+
bag /= 2
508+
503509
bag = bag_reference = self.bag_type('abracadabra')
504510
bag //= 2
505511
assert bag == self.bag_type('aabr')
@@ -665,7 +671,7 @@ def test_mutating(self):
665671
# decimal bag is unheard of.
666672
bag = bag_reference
667673
with cute_testing.RaiseAssertor(TypeError):
668-
bag['a'] /= 2
674+
bag /= 2
669675

670676
bag = bag_reference
671677
bag //= 3

source_py3/python_toolbox/logic_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def all_equivalent(iterable, relation=operator.eq, *, assume_reflexive=True,
6060
return all(itertools.starmap(relation, pairs))
6161

6262

63-
def get_equivalence_classes(iterable, key=None, container=set, *
63+
def get_equivalence_classes(iterable, key=None, container=set, *,
6464
use_ordered_dict=False, sort_ordered_dict=False):
6565
'''
6666
Divide items in `iterable` to equivalence classes, using the key function.

source_py3/test_python_toolbox/test_nifty_collections/test_bagging.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,9 @@ def test_mutating(self):
453453
assert bag == self.bag_type('abracadabra' + 'a' * 5)
454454
assert bag is bag_reference
455455

456-
# We only allow floor division on bags, not regular divison, because a
457-
# decimal bag is unheard of.
458456
bag = bag_reference = self.bag_type('abracadabra')
459457
with cute_testing.RaiseAssertor(TypeError):
460-
bag['a'] /= 2
458+
bag['a'] /= 2 # Won't work because `bag['a']` happens to be odd.
461459

462460
bag = bag_reference = self.bag_type('abracadabra')
463461
bag['a'] //= 2
@@ -499,6 +497,12 @@ def test_mutating(self):
499497
assert bag == self.bag_type('abracadabra' * 2)
500498
assert bag is bag_reference
501499

500+
# We only allow floor division on bags, not regular divison, because a
501+
# decimal bag is unheard of.
502+
bag = bag_reference = self.bag_type('abracadabra')
503+
with cute_testing.RaiseAssertor(TypeError):
504+
bag /= 2
505+
502506
bag = bag_reference = self.bag_type('abracadabra')
503507
bag //= 2
504508
assert bag == self.bag_type('aabr')
@@ -626,7 +630,7 @@ def test_mutating(self):
626630
with cute_testing.RaiseAssertor(TypeError):
627631
bag['a'] *= 2
628632
with cute_testing.RaiseAssertor(TypeError):
629-
bag['a'] /= 2
633+
bag['a'] /= 2
630634
with cute_testing.RaiseAssertor(TypeError):
631635
bag['a'] //= 2
632636
with cute_testing.RaiseAssertor(TypeError):
@@ -664,7 +668,7 @@ def test_mutating(self):
664668
# decimal bag is unheard of.
665669
bag = bag_reference
666670
with cute_testing.RaiseAssertor(TypeError):
667-
bag['a'] /= 2
671+
bag /= 2
668672

669673
bag = bag_reference
670674
bag //= 3

0 commit comments

Comments
 (0)