Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tomlkit 0.10.0 #9

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pysen.setting import SettingFile

MULTIPLE_SPACES = re.compile(r"\s+")
TOOL_HEADING = "[tool]\n"


def normalize_spaces(s: str) -> str:
Expand Down Expand Up @@ -71,8 +72,7 @@ def _assert_toml(path: pathlib.Path, expected: SettingFile) -> None:

def test_dump_toml(temp_file: pathlib.Path, test_nested_data: SettingFile) -> None:
dumper.dump_toml(temp_file, test_nested_data)
expected = """[tool]
[tool.bar] # automatically generated by pysen
expected = """[tool.bar] # automatically generated by pysen
a = 1.0
b = 12345
c = "yes"
Expand All @@ -94,6 +94,10 @@ def test_dump_toml(temp_file: pathlib.Path, test_nested_data: SettingFile) -> No

with temp_file.open("r") as f:
actual = f.read()

# NOTE: tomlkit 0.10+ won't create a super table if the table has only one child
if actual.startswith(TOOL_HEADING):
actual = actual[len(TOOL_HEADING) :]
assert normalize_spaces(actual) == normalize_spaces(expected)


Expand Down