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
77cd7a6e
Commit
77cd7a6e
authored
Apr 14, 2015
by
Rory Finnegan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed 2/3 compatibility issues in parsing/yaml/test_loader with six.
parent
7e9292c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
v2/test/parsing/yaml/test_loader.py
+9
-7
No files found.
v2/test/parsing/yaml/test_loader.py
View file @
77cd7a6e
...
...
@@ -20,6 +20,7 @@
from
__future__
import
(
absolute_import
,
division
,
print_function
)
__metaclass__
=
type
from
six
import
text_type
,
binary_type
from
six.moves
import
StringIO
from
collections
import
Sequence
,
Set
,
Mapping
...
...
@@ -28,6 +29,7 @@ from ansible.compat.tests.mock import patch
from
ansible.parsing.yaml.loader
import
AnsibleLoader
class
TestAnsibleLoaderBasic
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -52,7 +54,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
loader
=
AnsibleLoader
(
stream
,
'myfile.yml'
)
data
=
loader
.
get_single_data
()
self
.
assertEqual
(
data
,
u'Ansible'
)
self
.
assertIsInstance
(
data
,
unicod
e
)
self
.
assertIsInstance
(
data
,
text_typ
e
)
self
.
assertEqual
(
data
.
ansible_pos
,
(
'myfile.yml'
,
2
,
17
))
...
...
@@ -63,7 +65,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
loader
=
AnsibleLoader
(
stream
,
'myfile.yml'
)
data
=
loader
.
get_single_data
()
self
.
assertEqual
(
data
,
u'Cafè Eñyei'
)
self
.
assertIsInstance
(
data
,
unicod
e
)
self
.
assertIsInstance
(
data
,
text_typ
e
)
self
.
assertEqual
(
data
.
ansible_pos
,
(
'myfile.yml'
,
2
,
17
))
...
...
@@ -76,8 +78,8 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
data
=
loader
.
get_single_data
()
self
.
assertEqual
(
data
,
{
'webster'
:
'daniel'
,
'oed'
:
'oxford'
})
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertIsInstance
(
data
.
keys
()[
0
],
unicod
e
)
self
.
assertIsInstance
(
data
.
values
()[
0
],
unicod
e
)
self
.
assertIsInstance
(
list
(
data
.
keys
())[
0
],
text_typ
e
)
self
.
assertIsInstance
(
list
(
data
.
values
())[
0
],
text_typ
e
)
# Beginning of the first key
self
.
assertEqual
(
data
.
ansible_pos
,
(
'myfile.yml'
,
2
,
17
))
...
...
@@ -94,7 +96,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
data
=
loader
.
get_single_data
()
self
.
assertEqual
(
data
,
[
u'a'
,
u'b'
])
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertIsInstance
(
data
[
0
],
unicod
e
)
self
.
assertIsInstance
(
data
[
0
],
text_typ
e
)
self
.
assertEqual
(
data
.
ansible_pos
,
(
'myfile.yml'
,
2
,
17
))
...
...
@@ -204,10 +206,10 @@ class TestAnsibleLoaderPlay(unittest.TestCase):
def
walk
(
self
,
data
):
# Make sure there's no str in the data
self
.
assertNotIsInstance
(
data
,
str
)
self
.
assertNotIsInstance
(
data
,
binary_type
)
# Descend into various container types
if
isinstance
(
data
,
unicod
e
):
if
isinstance
(
data
,
text_typ
e
):
# strings are a sequence so we have to be explicit here
return
elif
isinstance
(
data
,
(
Sequence
,
Set
)):
...
...
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