@@ -41,7 +41,18 @@ def test_module_name():
4141 assert toolz .curried .__name__ == 'toolz.curried'
4242
4343
44+ def should_curry (func ):
45+ if not callable (func ) or isinstance (func , toolz .curry ):
46+ return False
47+ nargs = toolz .functoolz .num_required_args (func )
48+ if nargs is None or nargs > 1 :
49+ return True
50+ return nargs == 1 and toolz .functoolz .has_keywords (func )
51+
52+
4453def test_curried_operator ():
54+ import operator
55+
4556 for k , v in vars (cop ).items ():
4657 if not callable (v ):
4758 continue
@@ -60,6 +71,7 @@ def test_curried_operator():
6071 raise AssertionError (
6172 'toolz.curried.operator.%s is not curried!' % k ,
6273 )
74+ assert should_curry (getattr (operator , k )) == isinstance (v , toolz .curry ), k
6375
6476 # Make sure this isn't totally empty.
6577 assert len (set (vars (cop )) & {'add' , 'sub' , 'mul' }) == 3
@@ -69,14 +81,6 @@ def test_curried_namespace():
6981 exceptions = import_module ('toolz.curried.exceptions' )
7082 namespace = {}
7183
72- def should_curry (func ):
73- if not callable (func ) or isinstance (func , toolz .curry ):
74- return False
75- nargs = toolz .functoolz .num_required_args (func )
76- if nargs is None or nargs > 1 :
77- return True
78- return nargs == 1 and toolz .functoolz .has_keywords (func )
79-
8084
8185 def curry_namespace (ns ):
8286 return {
0 commit comments