Skip to content

Commit 11c7611

Browse files
committed
Add test for all dictionary types.
1 parent 9717ac9 commit 11c7611

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

tests/test_toml_parser/test_parse_file.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def test_insert_index(tmp_path):
339339
assert expected == actual
340340

341341

342-
def test_dict(tmp_path):
342+
def test_inline_table(tmp_path):
343343
expected = {"SOMETHING": {"blob": "hello"}}
344344

345345
path = tmp_path / "pyproject.toml"
@@ -356,7 +356,7 @@ def test_dict(tmp_path):
356356
assert expected == actual
357357

358358

359-
def test_dict_section(tmp_path):
359+
def test_table(tmp_path):
360360
expected = {"SOMETHING": {"blob": "hello"}}
361361

362362
path = tmp_path / "pyproject.toml"
@@ -370,6 +370,39 @@ def test_dict_section(tmp_path):
370370
assert expected == actual
371371

372372

373+
def test_all_dictionaries(tmp_path):
374+
path = tmp_path / "pyproject.toml"
375+
376+
expected = {"DATABASES": {"default": {"ENGINE": "django.db.backends.postgresql"}}}
377+
378+
# inline table
379+
path.write_text("""
380+
[tool.django]
381+
DATABASES = { default = { ENGINE = "django.db.backends.postgresql" } }
382+
""")
383+
384+
actual = parse_file(path)
385+
assert expected == actual
386+
387+
# table for DATABASES
388+
path.write_text("""
389+
[tool.django.DATABASES]
390+
default = { ENGINE = "django.db.backends.postgresql" }
391+
""")
392+
393+
actual = parse_file(path)
394+
assert expected == actual
395+
396+
# table for DATABASES.default
397+
path.write_text("""
398+
[tool.django.DATABASES.default]
399+
ENGINE = "django.db.backends.postgresql"
400+
""")
401+
402+
actual = parse_file(path)
403+
assert expected == actual
404+
405+
373406
def test_variable(tmp_path):
374407
expected = {"SOMETHING": "hello", "SOMETHING2": "hello"}
375408

0 commit comments

Comments
 (0)