Skip to content

Commit

Permalink
test Size.from_pyproject_toml
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantin Gahr committed Sep 13, 2024
1 parent 451b1ac commit 8d8b39c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/test_10_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,46 @@ def test_str(self, size):

def test_repr(self, size):
repr(size)

def test_from_pyproject_toml_complete(self, tmp_path):
width = 123
height = 456
path = tmp_path / "pyproject.toml"
with path.open("w") as fh:
fh.writelines(
[
"[tool.latexplotlib]\n",
f"width = {width}\n",
f"height = {height}\n",
]
)

size = cfg.Size.from_pyproject_toml(path)
assert size._width == width
assert size._height == height

def test_from_pyproject_toml_empty(self, tmp_path):
path = tmp_path / "pyproject.toml"
path.touch()

size = cfg.Size.from_pyproject_toml(path)
assert size._width == cfg.DEFAULT_WIDTH
assert size._height == cfg.DEFAULT_HEIGHT

def test_from_pyproject_toml_tool(self, tmp_path):
path = tmp_path / "pyproject.toml"
with path.open("w") as fh:
fh.writelines(["[tool]\n"])

size = cfg.Size.from_pyproject_toml(path)
assert size._width == cfg.DEFAULT_WIDTH
assert size._height == cfg.DEFAULT_HEIGHT

def test_from_pyproject_toml_tool_latexplotlib(self, tmp_path):
path = tmp_path / "pyproject.toml"
with path.open("w") as fh:
fh.writelines(["[tool.latexplotlib]\n"])

size = cfg.Size.from_pyproject_toml(path)
assert size._width == cfg.DEFAULT_WIDTH
assert size._height == cfg.DEFAULT_HEIGHT

0 comments on commit 8d8b39c

Please sign in to comment.