Skip to content

Commit a7c2110

Browse files
committed
Add test for seq delay
1 parent 414db69 commit a7c2110

File tree

2 files changed

+44
-29
lines changed

2 files changed

+44
-29
lines changed

.pre-commit-config.yaml

+28-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
exclude: "_version.py|versioneer.py"
22
repos:
3-
- hooks:
4-
- args:
5-
- --remove-all-unused-imports
6-
- --in-place
7-
id: autoflake
8-
repo: https://github.com/humitos/mirrors-autoflake
9-
rev: v1.1
10-
- hooks:
11-
- id: isort
12-
repo: https://github.com/timothycrosley/isort
13-
rev: 5.6.4
14-
- hooks:
15-
- id: black
16-
repo: https://github.com/psf/black
17-
rev: 20.8b1
18-
- hooks:
19-
- id: flake8
20-
repo: https://gitlab.com/pycqa/flake8
21-
rev: 3.8.4
22-
- hooks:
23-
- id: pyright
24-
name: pyright
25-
entry: pyright
26-
language: node
27-
pass_filenames: false
28-
types: [python]
29-
additional_dependencies: ['[email protected]']
30-
repo: local
31-
3+
- hooks:
4+
- args:
5+
- --remove-all-unused-imports
6+
- --in-place
7+
id: autoflake
8+
repo: https://github.com/humitos/mirrors-autoflake
9+
rev: v1.1
10+
- hooks:
11+
- id: isort
12+
repo: https://github.com/timothycrosley/isort
13+
rev: 5.6.4
14+
- hooks:
15+
- id: black
16+
repo: https://github.com/psf/black
17+
rev: 20.8b1
18+
- hooks:
19+
- id: flake8
20+
repo: https://gitlab.com/pycqa/flake8
21+
rev: 3.8.4
22+
- hooks:
23+
- id: pyright
24+
name: pyright
25+
entry: pyright
26+
language: node
27+
pass_filenames: false
28+
types: [python]
29+
additional_dependencies: ["[email protected]"]
30+
repo: local

tests/test_seq.py

+16
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,22 @@ def test_seq_pipeline(xs: List[int]):
212212
assert ys == functools.reduce(lambda s, x: s + x, filter(lambda x: x > 100, map(lambda x: x * 10, xs)), 0)
213213

214214

215+
@given(st.lists(st.integers()))
216+
def test_seq_delay(xs: List[int]):
217+
ran = False
218+
219+
def generator():
220+
nonlocal ran
221+
ran = True
222+
return seq.of_list(xs)
223+
224+
ys = seq.delay(generator)
225+
assert not ran
226+
227+
assert list(ys) == xs
228+
assert ran
229+
230+
215231
def test_seq_choose_option():
216232
xs: Iterable[Optional[int]] = seq.of(None, 42)
217233

0 commit comments

Comments
 (0)