-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split tests into modules, use pytest, 100% coverage
- Loading branch information
Showing
17 changed files
with
533 additions
and
372 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ docs/_build/ | |
.coverage | ||
.coverage.* | ||
htmlcov/ | ||
.hypothesis/ |
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
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
Empty file.
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,11 @@ | ||
import pytest | ||
|
||
from itsdangerous._compat import _constant_time_compare | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("a", "b", "expect"), | ||
((b"a", b"a", True), (b"a", b"b", False), (b"a", b"aa", False)), | ||
) | ||
def test_python_constant_time_compare(a, b, expect): | ||
assert _constant_time_compare(a, b) == expect |
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,38 @@ | ||
# -*- coding: utf-8 -*- | ||
import pytest | ||
|
||
from itsdangerous.encoding import base64_decode | ||
from itsdangerous.encoding import base64_encode | ||
from itsdangerous.encoding import bytes_to_int | ||
from itsdangerous.encoding import int_to_bytes | ||
from itsdangerous.encoding import want_bytes | ||
from itsdangerous.exc import BadData | ||
|
||
|
||
@pytest.mark.parametrize("value", (u"mañana", b"tomorrow")) | ||
def test_want_bytes(value): | ||
out = want_bytes(value) | ||
assert isinstance(out, bytes) | ||
|
||
|
||
@pytest.mark.parametrize("value", (u"無限", b"infinite")) | ||
def test_base64(value): | ||
enc = base64_encode(value) | ||
assert isinstance(enc, bytes) | ||
dec = base64_decode(enc) | ||
assert dec == want_bytes(value) | ||
|
||
|
||
def test_base64_bad(): | ||
with pytest.raises(BadData): | ||
base64_decode("12345") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("value", "expect"), ((0, b""), (192, b"\xc0"), (18446744073709551615, b"\xff" * 8)) | ||
) | ||
def test_int_bytes(value, expect): | ||
enc = int_to_bytes(value) | ||
assert enc == expect | ||
dec = bytes_to_int(enc) | ||
assert dec == value |
Oops, something went wrong.