@@ -41,7 +41,7 @@ def test_enumerate():
4141 assert list (data | pipe .enumerate (start = 5 )) == expected
4242
4343
44- def test_class_support ():
44+ def test_class_support_on_methods ():
4545 class Factory :
4646 n = 10
4747
@@ -52,6 +52,34 @@ def mul(self, iterable):
5252 assert list ([1 , 2 , 3 ] | Factory ().mul ) == [10 , 20 , 30 ]
5353
5454
55+ def test_class_support_on_static_methods ():
56+ class TenFactory :
57+ @pipe .Pipe
58+ @staticmethod
59+ def mul (iterable ):
60+ return (x * 10 for x in iterable )
61+
62+ assert list ([1 , 2 , 3 ] | TenFactory .mul ) == [10 , 20 , 30 ]
63+
64+
65+ def test_class_support_on_class_methods ():
66+ class Factory :
67+ n = 10
68+
69+ @pipe .Pipe
70+ @classmethod
71+ def mul (cls , iterable ):
72+ return (x * cls .n for x in iterable )
73+
74+ assert list ([1 , 2 , 3 ] | Factory .mul ) == [10 , 20 , 30 ]
75+
76+ Factory .n = 2
77+ assert list ([1 , 2 , 3 ] | Factory .mul ) == [2 , 4 , 6 ]
78+
79+ obj = Factory ()
80+ assert list ([1 , 2 , 3 ] | obj .mul ) == [2 , 4 , 6 ]
81+
82+
5583def test_class_support_with_named_parameter ():
5684 class Factory :
5785 @pipe .Pipe
0 commit comments