forked from Suor/funcy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make autocurry() and friends support kw-only and pos-only arguments
- Loading branch information
Showing
4 changed files
with
93 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
from funcy.funcs import autocurry | ||
|
||
|
||
def test_autocurry_posonly(): | ||
at = autocurry(lambda a, /, b: (a, b)) | ||
assert at(1)(b=2) == (1, 2) | ||
assert at(b=2)(1) == (1, 2) | ||
with pytest.raises(TypeError): at(a=1)(b=2) | ||
|
||
at = autocurry(lambda a, /, **kw: (a, kw)) | ||
assert at(a=2)(1) == (1, {'a': 2}) | ||
|
||
at = autocurry(lambda a=1, /, *, b: (a, b)) | ||
assert at(b=2) == (1, 2) | ||
assert at(0)(b=3) == (0, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters