Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from joke2k/feature/cache-url-test
Safely evaluate a string containing an invalid Python literal
- Loading branch information
Showing
4 changed files
with
103 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
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,22 @@ | ||
# This file is part of the django-environ. | ||
# | ||
# Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | ||
# Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> | ||
# | ||
# For the full copyright and license information, please view | ||
# the LICENSE.txt file that was distributed with this source code. | ||
|
||
import pytest | ||
from environ.environ import _cast | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'literal', | ||
['anything-', 'anything*', '*anything', 'anything.', | ||
'anything.1', '(anything', 'anything-v1.2', 'anything-1.2', 'anything='] | ||
) | ||
def test_cast(literal): | ||
"""Safely evaluate a string containing an invalid Python literal. | ||
See https://github.com/joke2k/django-environ/issues/200 for details.""" | ||
assert _cast(literal) == literal |