Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
py-namelist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Claus
py-namelist
Commits
b3a5d90e
Commit
b3a5d90e
authored
Oct 04, 2018
by
Martin Claus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for stringification
parent
44901c89
Pipeline
#1897
failed with stage
in 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
tests/test_parsing.py
tests/test_parsing.py
+27
-0
No files found.
tests/test_parsing.py
View file @
b3a5d90e
...
...
@@ -242,6 +242,33 @@ def test_index_assignment(string, val1, d):
print
(
repr
(
nml
),
d
)
assert
nml
[
"val"
]
==
d
@
pytest
.
mark
.
parametrize
(
"string"
,
[
"&nml {} /"
,
"&nml {} val2=34 /"
])
@
pytest
.
mark
.
parametrize
(
"val1"
,
[
"lala"
,
"((1 + 2) + 3)"
,
3
,
3.0
,
3e6
,
".T."
])
@
pytest
.
mark
.
parametrize
(
"d"
,
[{
1
:
None
,
2
:
35
},{
1
:
None
}])
def
test_index_assignment_to_str
(
string
,
d
,
val1
):
val_str
=
""
try
:
int
(
eval
(
val1
))
is_expression
=
True
except
:
is_expression
=
False
is_bool
=
(
val1
==
".T."
)
d
[
1
]
=
val1
for
k
,
v
in
d
.
items
():
if
is_expression
|
is_bool
:
val_str
+=
"val({}) = {} "
.
format
(
k
,
v
)
else
:
val_str
+=
"val({}) = {} "
.
format
(
k
,
repr
(
v
))
if
is_expression
:
d
[
1
]
=
eval
(
d
[
1
])
if
is_bool
:
d
[
1
]
=
(
val1
==
".T."
)
nml_string
=
string
.
format
(
val_str
)
nml
=
namelist
.
parse_namelist_string
(
nml_string
)[
"nml"
]
assert
nml_string
==
str
(
nml
)
@
pytest
.
mark
.
parametrize
(
"string"
,
[
"&nml val= {}, val2='lsl'/"
])
@
pytest
.
mark
.
parametrize
(
"op"
,
[
"+"
,
"-"
,
"/"
,
"*"
,
"**"
])
@
pytest
.
mark
.
parametrize
(
...
...
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