Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
6b8faf57
Commit
6b8faf57
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
extend hint_with_length
parent
9c362326
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/iterators.py
+9
-0
9 additions, 0 deletions
satella/coding/iterators.py
tests/test_coding/test_iterators.py
+1
-16
1 addition, 16 deletions
tests/test_coding/test_iterators.py
with
13 additions
and
17 deletions
CHANGELOG.md
+
2
−
0
View file @
6b8faf57
# v2.7.35
# v2.7.35
*
enabled
`hint_with_length`
to take generator-creating
functions as argument
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
6b8faf57
__version__
=
'
2.7.35_a
1
'
__version__
=
'
2.7.35_a
2
'
This diff is collapsed.
Click to expand it.
satella/coding/iterators.py
+
9
−
0
View file @
6b8faf57
...
@@ -78,6 +78,15 @@ class hint_with_length:
...
@@ -78,6 +78,15 @@ class hint_with_length:
self
.
generator
=
generator
self
.
generator
=
generator
self
.
length
=
length
self
.
length
=
length
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
hint_with_length
(
self
.
generator
(
*
args
,
**
kwargs
),
self
.
length
)
def
close
(
self
):
return
self
.
generator
.
close
()
def
send
(
self
,
obj
):
return
self
.
generator
.
send
(
obj
)
def
__iter__
(
self
):
def
__iter__
(
self
):
return
self
.
generator
return
self
.
generator
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_iterators.py
+
1
−
16
View file @
6b8faf57
...
@@ -10,24 +10,9 @@ class TestIterators(unittest.TestCase):
...
@@ -10,24 +10,9 @@ class TestIterators(unittest.TestCase):
for
i
in
range
(
1000
):
for
i
in
range
(
1000
):
yield
i
yield
i
g
=
hint_with_length
(
generator
()
,
1000
)
g
=
hint_with_length
(
generator
,
1000
)
()
self
.
assertEqual
(
g
.
__length_hint__
(),
1000
)
self
.
assertEqual
(
g
.
__length_hint__
(),
1000
)
@unittest.skipUnless
(
sys
.
implementation
.
name
==
'
cpython
'
,
'
Not CPython, this needs deterministic GC
'
)
def
test_self_closing_generator
(
self
):
a
=
{
'
done
'
:
False
}
def
generator
():
for
i
in
range
(
5
):
yield
i
a
[
'
done
'
]
=
True
for
i
in
SelfClosingGenerator
(
generator
()):
if
i
==
2
:
break
self
.
assertTrue
(
a
[
'
done
'
])
@unittest.skipUnless
(
sys
.
implementation
.
name
==
'
cpython
'
,
'
Not CPython, this needs deterministic GC
'
)
@unittest.skipUnless
(
sys
.
implementation
.
name
==
'
cpython
'
,
'
Not CPython, this needs deterministic GC
'
)
def
test_self_closing_generator_function
(
self
):
def
test_self_closing_generator_function
(
self
):
a
=
{
'
done
'
:
False
}
a
=
{
'
done
'
:
False
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment