Skip to content

Commit de022de

Browse files
committed
add some more tests
1 parent 1299803 commit de022de

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ run.omit = [
6060
"tests/*.py",
6161
# add others
6262
]
63+
run.plugins = [
64+
# all plugins
65+
"covdefaults",
66+
]
6367

6468

6569
[tool.tox]

tests/test_pipe.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
5583
def test_class_support_with_named_parameter():
5684
class Factory:
5785
@pipe.Pipe

0 commit comments

Comments
 (0)