Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
45aac6a7
Commit
45aac6a7
authored
Sep 02, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding unit tests for safe_eval
parent
41da8de0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
test/units/template/test_safe_eval.py
+26
-0
No files found.
test/units/template/test_safe_eval.py
View file @
45aac6a7
...
...
@@ -19,3 +19,29 @@
from
__future__
import
(
absolute_import
,
division
,
print_function
)
__metaclass__
=
type
from
collections
import
defaultdict
from
ansible.compat.tests
import
unittest
from
ansible.compat.tests.mock
import
patch
,
MagicMock
from
ansible.template.safe_eval
import
safe_eval
class
TestSafeEval
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
tearDown
(
self
):
pass
def
test_safe_eval_usage
(
self
):
# test safe eval calls with different possible types for the
# locals dictionary, to ensure we don't run into problems like
# ansible/ansible/issues/12206 again
for
locals_vars
in
(
dict
(),
defaultdict
(
dict
)):
self
.
assertEqual
(
safe_eval
(
'True'
,
locals
=
locals_vars
),
True
)
self
.
assertEqual
(
safe_eval
(
'False'
,
locals
=
locals_vars
),
False
)
self
.
assertEqual
(
safe_eval
(
'0'
,
locals
=
locals_vars
),
0
)
self
.
assertEqual
(
safe_eval
(
'[]'
,
locals
=
locals_vars
),
[])
self
.
assertEqual
(
safe_eval
(
'{}'
,
locals
=
locals_vars
),
{})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment