-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove the unused `ComplexAdapter` class * add tests for the untested `Factor` * add a test for the datetime converter * fix a off-by-one error in the datetime converter * add tests for the second datetime constructor * add a test for the metadata injector * convert the ascii integer function into the adapter's constructor * strip ascii integers on both ends of the string * don't save the number of bytes on the adapter * same for padded string, and ascii float and ascii complex * verify that all adapters do not implement `_encode` * add tests for `StripNullBytes` * configure `coverage.py` * trigger the translator's validator * ignore the fallback import in coverage reports * add tests for `itemsplit` * add tests for `keysplit` and `valsplit`
- Loading branch information
Showing
6 changed files
with
223 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
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,39 @@ | ||
import pytest | ||
|
||
from ceos_alos2 import dicttoolz | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["data", "expected"], | ||
( | ||
pytest.param( | ||
{1: 0, 2: 1, 3: 2}, | ||
({3: 2}, {1: 0, 2: 1}), | ||
), | ||
pytest.param( | ||
{1: 0, 3: 0, 2: 1}, | ||
({}, {1: 0, 3: 0, 2: 1}), | ||
), | ||
), | ||
) | ||
def test_itemsplit(data, expected): | ||
predicate = lambda item: item[0] % 2 == 1 and item[1] != 0 | ||
|
||
actual = dicttoolz.itemsplit(predicate, data) | ||
assert actual == expected | ||
|
||
|
||
def test_valsplit(): | ||
data = {0: 1, 1: 0, 2: 2} | ||
actual = dicttoolz.valsplit(lambda v: v != 0, data) | ||
expected = ({0: 1, 2: 2}, {1: 0}) | ||
|
||
assert actual == expected | ||
|
||
|
||
def test_keysplit(): | ||
data = {0: 1, 1: 0, 2: 2} | ||
actual = dicttoolz.keysplit(lambda k: k % 2 == 0, data) | ||
expected = ({0: 1, 2: 2}, {1: 0}) | ||
|
||
assert actual == expected |
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