-
Notifications
You must be signed in to change notification settings - Fork 144
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
b95c76f
commit 2bd7ece
Showing
2 changed files
with
39 additions
and
1 deletion.
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,38 @@ | ||
from __future__ import annotations | ||
|
||
from whitenoise.string_utils import decode_if_byte_string, ensure_leading_trailing_slash | ||
|
||
|
||
class DecodeIfByteStringTests: | ||
def test_bytes(self): | ||
assert decode_if_byte_string(b"abc") == "abc" | ||
|
||
def test_unforced(self): | ||
x = object() | ||
assert decode_if_byte_string(x) is x | ||
|
||
def test_forced(self): | ||
x = object() | ||
result = decode_if_byte_string(x, force_text=True) | ||
assert isinstance(result, str) | ||
assert result.startswith("<object object at ") | ||
|
||
|
||
class EnsureLeadingTrailingSlashTests: | ||
def test_none(self): | ||
assert ensure_leading_trailing_slash(None) == "/" | ||
|
||
def test_empty(self): | ||
assert ensure_leading_trailing_slash("") == "/" | ||
|
||
def test_slash(self): | ||
assert ensure_leading_trailing_slash("/") == "/" | ||
|
||
def test_contents(self): | ||
assert ensure_leading_trailing_slash("/foo/") == "/foo/" | ||
|
||
def test_leading(self): | ||
assert ensure_leading_trailing_slash("/foo") == "/foo" | ||
|
||
def test_trailing(self): | ||
assert ensure_leading_trailing_slash("foo/") == "/foo" |