2021-05-04 13:12:02 +00:00
|
|
|
import unittest
|
|
|
|
|
2022-10-14 14:53:06 +00:00
|
|
|
from benedict import benedict
|
|
|
|
|
2021-05-04 13:12:02 +00:00
|
|
|
|
|
|
|
class github_issue_0053_test_case(unittest.TestCase):
|
|
|
|
"""
|
2022-02-13 10:35:43 +00:00
|
|
|
This class describes a github issue 0053 test case.
|
2021-05-04 13:12:02 +00:00
|
|
|
https://github.com/fabiocaccamo/python-benedict/issues/53
|
|
|
|
|
|
|
|
To run this specific test:
|
|
|
|
- Run python -m unittest tests.github.test_issue_0053
|
|
|
|
"""
|
2022-02-13 10:35:43 +00:00
|
|
|
|
2021-05-04 13:12:02 +00:00
|
|
|
def test_toml_dump_circular_reference(self):
|
2022-02-13 10:35:43 +00:00
|
|
|
toml_str = """[build-system]
|
2021-05-04 13:12:02 +00:00
|
|
|
requires = [ "poetry-core>=1.0.0",]
|
|
|
|
build-backend = "poetry.core.masonry.api"
|
|
|
|
|
|
|
|
[tool.poetry]
|
|
|
|
name = "hermes"
|
|
|
|
version = "0.5.21"
|
|
|
|
description = "CI tool using Poetry"
|
|
|
|
authors = [ "Francisco Algaba <...>",]
|
|
|
|
readme = "README.md"
|
|
|
|
|
|
|
|
[tool.poetry.scripts]
|
|
|
|
hermes = "hermes.main:app"
|
|
|
|
|
|
|
|
[tool.poetry.dependencies]
|
|
|
|
python = ">=3.6.1,<4.0.0"
|
|
|
|
python-benedict = "^0.23.2"
|
|
|
|
mkdocs-material = "^7.1.2"
|
|
|
|
mkdocstrings = "^0.15.0"
|
|
|
|
mkdocs = "^1.1.2"
|
|
|
|
shiv = "^0.4.0"
|
|
|
|
pytest-json-report = "^1.2.4"
|
|
|
|
cruft = "^2.8.0"
|
|
|
|
|
|
|
|
[tool.poetry.dev-dependencies]
|
|
|
|
pytest = "^5.2"
|
|
|
|
Pygments = "^2.8.1"
|
|
|
|
pre-commit = "^2.12.0"
|
|
|
|
isort = "^5.8.0"
|
|
|
|
|
|
|
|
[tool.poetry.dependencies.typer]
|
|
|
|
extras = [ "all",]
|
|
|
|
version = "^0.3.2"
|
|
|
|
|
|
|
|
[tool.poetry.dev-dependencies.black]
|
|
|
|
version = "^20.8b1"
|
|
|
|
allow-prereleases = true
|
|
|
|
"""
|
|
|
|
toml_dict = benedict.from_toml(toml_str)
|
2022-02-13 10:35:43 +00:00
|
|
|
toml_dict["tool.poetry.name"] = "new name with custom value"
|
2021-05-04 13:12:02 +00:00
|
|
|
# print(toml_dict.dump())
|
|
|
|
toml_str_new = toml_dict.to_toml()
|
|
|
|
# print(toml_str_new)
|
2022-02-13 10:35:43 +00:00
|
|
|
self.assertTrue("new name with custom value" in toml_str_new)
|