25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

cfg_aux_test.py 1.2KB

3 ay önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from cfg_aux import *
  2. def test_cfg_aux_tree(
  3. ) -> str:
  4. lines = [
  5. "[abc]",
  6. "width = 100",
  7. "wrongSep=another",
  8. "[def]",
  9. "anotherWrongSep -> whatever",
  10. "title = yo",
  11. "subtitle = whoa",
  12. ]
  13. tree = cfg_aux_tree(lines)
  14. if (
  15. cld_len(tree) == 2 and
  16. cld_len(tree["abc"]) == 1 and
  17. cld_len(tree["def"]) == 2
  18. ):
  19. return "OK: cfg_aux_tree"
  20. return "ERR: cfg_aux_tree"
  21. def test_cfg_aux_treeCreateSection(
  22. ) -> str:
  23. tree: dict[str, dict[str, str]] = {}
  24. line = "[abc]"
  25. sectionName = cfg_aux_treeCreateSection(tree, line)
  26. if (
  27. sectionName == "abc" and
  28. cld_len(tree) == 1
  29. ):
  30. return "OK: cfg_aux_treeCreateSection"
  31. return "ERR: cfg_aux_treeCreateSection"
  32. def test_cfg_aux_treeSetKeyValue(
  33. ) -> str:
  34. tree: dict[str, dict[str, str]] = {}
  35. line = "[abc]"
  36. sectionName = cfg_aux_treeCreateSection(tree, line)
  37. line = "title = wazup"
  38. cfg_aux_treeSetKeyValue(tree, sectionName, line)
  39. if (
  40. cld_len(tree[sectionName]) == 1 and
  41. tree[sectionName]["title"] == "wazup"
  42. ):
  43. return "OK: cfg_aux_treeSetKeyValue"
  44. return "ERR: cfg_aux_treeSetKeyValue"