Add TMT test for upstream ticket 534
Signed-off-by: Ondrej Mosnáček <omosnacek@gmail.com>
This commit is contained in:
parent
7ce90a3638
commit
6399b356b8
5 changed files with 45 additions and 0 deletions
1
.fmf/version
Normal file
1
.fmf/version
Normal file
|
|
@ -0,0 +1 @@
|
|||
1
|
||||
6
plans/ci.fmf
Normal file
6
plans/ci.fmf
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
summary: Run CI tests
|
||||
discover:
|
||||
how: fmf
|
||||
execute:
|
||||
how: tmt
|
||||
|
||||
1
tests/main.fmf
Normal file
1
tests/main.fmf
Normal file
|
|
@ -0,0 +1 @@
|
|||
component: python-ruamel-yaml
|
||||
5
tests/sf534/main.fmf
Normal file
5
tests/sf534/main.fmf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
summary: Regression test for upstream ticket 534
|
||||
require: python3-ruamel-yaml
|
||||
link:
|
||||
- verifies: https://sourceforge.net/p/ruamel-yaml/tickets/534/
|
||||
test: python3 test.py
|
||||
32
tests/sf534/test.py
Normal file
32
tests/sf534/test.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Taken from https://sourceforge.net/p/ruamel-yaml/tickets/534/
|
||||
|
||||
from io import StringIO
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
original = '0: foo\n'
|
||||
py_original = {0: 'foo'}
|
||||
prefix = '%YAML 1.1\n---\n'
|
||||
|
||||
yaml = YAML()
|
||||
yaml.version = (1, 1)
|
||||
|
||||
loaded = yaml.load(original)
|
||||
assert loaded == py_original
|
||||
|
||||
print('Fresh')
|
||||
stream = StringIO()
|
||||
yaml.dump(py_original, stream)
|
||||
fresh = stream.getvalue()
|
||||
print(fresh)
|
||||
assert fresh.startswith(prefix)
|
||||
trimmed = fresh[len(prefix):]
|
||||
assert trimmed == original, f"{trimmed!r} != {original!r}"
|
||||
|
||||
print('Round trip')
|
||||
stream = StringIO()
|
||||
yaml.dump(loaded, stream)
|
||||
round_tripped = stream.getvalue()
|
||||
print(round_tripped)
|
||||
assert round_tripped.startswith(prefix)
|
||||
trimmed = round_tripped[len(prefix):]
|
||||
assert trimmed == original, f"{trimmed!r} != {original!r}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue