Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_yaml_parser.py 764 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  1. import pytest
  2. import yaml
  3. from yaml import CLoader as Loader
  4. test_data = [
  5. (
  6. 'Should Parse Simple YAML',
  7. """
  8. a: 1
  9. b: 2.5
  10. c: "I love Ice Creams!!"
  11. d:
  12. p: true
  13. q: false
  14. """,
  15. dict(a=1, b=2.5, c='I love Ice Creams!!', d=dict(p=True, q=False))
  16. ),
  17. (
  18. 'Should Parse List Type in YAML',
  19. """
  20. a:
  21. - 1
  22. - 2.3
  23. - 4 string
  24. b: [1, 2.3, 4 string]
  25. """,
  26. dict.fromkeys(['a', 'b'], [1, 2.3, '4 string'])
  27. )
  28. ]
  29. @pytest.mark.parametrize('msg, parse_string, expected', test_data)
  30. def test_yaml_parsing(msg, parse_string, expected):
  31. result = yaml.load(parse_string, Loader)
  32. assert expected == result, msg
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...