Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Martin Claus
py-namelist
Commits
f26d989d
Commit
f26d989d
authored
Oct 02, 2018
by
Martin Claus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for parsing key-value pairs
parent
d2619685
Changes
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 @
f26d989d
...
...
@@ -9,9 +9,36 @@ from context import namelist
"string"
,
[
"&nml &end"
,
"&nml
\n
&end"
,
"&nml &"
,
"&nml /"
,
"&nml/"
,
]
)
def
test_parse_string
(
string
):
nml
=
namelist
.
parse_namelist_string
(
string
)[
0
]
assert
nml
.
name
==
"nml"
@
pytest
.
mark
.
parametrize
(
"string"
,
[
"&nml2 val=34 &end"
,
"&nml2
\n
val=34
\n
&end"
,
]
)
def
test_match_name_val
(
string
):
nml
=
namelist
.
parse_namelist_string
(
string
)[
0
]
assert
nml
.
name
==
"nml2"
assert
nml
[
"val"
]
==
34
@
pytest
.
mark
.
parametrize
(
"string"
,
[
"&nml3 val1=34, val2=35 &end"
,
"&nml3 val1=34 val2=35 &end"
,
"&nml3
\n
val1=34
\n
val2=35
\n
&end"
,
]
)
def
test_match_multiple_name_val
(
string
):
nml
=
namelist
.
parse_namelist_string
(
string
)[
0
]
assert
nml
.
name
==
"nml3"
assert
nml
[
"val1"
]
==
34
assert
nml
[
"val2"
]
==
35
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