-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c96c666
commit e0dcc7b
Showing
2 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# (C) Copyright 2020 ECMWF. | ||
# | ||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
# In applying this licence, ECMWF does not waive the privileges and immunities | ||
# granted to it by virtue of its status as an intergovernmental organisation | ||
# nor does it submit to any jurisdiction. | ||
# | ||
|
||
from climetlab.decorators import normalize | ||
|
||
|
||
def x_no_default(x): | ||
return x | ||
|
||
|
||
def test_int_list_normalizers(): | ||
g = x_no_default | ||
g = normalize("x", "int-list")(g) | ||
assert g(x=1) == [1] | ||
assert g(x=(1, 2)) == [1, 2] | ||
assert g(x=("1", 2)) == [1, 2] | ||
assert g(x="1") == [1] | ||
assert g(x="1/to/3") == [1, 2, 3] | ||
assert g(x="1/to/3/by/2") == [1, 3] | ||
|
||
|
||
if __name__ == "__main__": | ||
from climetlab.testing import main | ||
|
||
main(__file__) |