From: Daan De Meyer Date: Fri, 1 Sep 2023 09:43:57 +0000 (+0200) Subject: Use tmp_path fixture in test_parse_ini() X-Git-Tag: v16~23^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a42915ee602736ab8e522a2a2838579dc1870a9;p=thirdparty%2Fmkosi.git Use tmp_path fixture in test_parse_ini() --- diff --git a/tests/test_config.py b/tests/test_config.py index 2a70ae300..d68716ea3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1+ -import tempfile from pathlib import Path from mkosi.config import Compression, parse_ini @@ -36,32 +35,31 @@ def test_compression_enum_str() -> None: assert str(Compression.lzma) == "lzma" -def test_parse_ini() -> None: - with tempfile.TemporaryDirectory() as d: - p = Path(d) / "ini" - p.write_text( - """\ - [MySection] - Value=abc - Other=def - ALLCAPS=txt +def test_parse_ini(tmp_path: Path) -> None: + p = tmp_path / "ini" + p.write_text( + """\ + [MySection] + Value=abc + Other=def + ALLCAPS=txt - # Comment - ; Another comment - [EmptySection] - [AnotherSection] - EmptyValue= - Multiline=abc - def - qed - ord - """ - ) + # Comment + ; Another comment + [EmptySection] + [AnotherSection] + EmptyValue= + Multiline=abc + def + qed + ord + """ + ) - g = parse_ini(p) + g = parse_ini(p) - assert next(g) == ("MySection", "Value", "abc") - assert next(g) == ("MySection", "Other", "def") - assert next(g) == ("MySection", "ALLCAPS", "txt") - assert next(g) == ("AnotherSection", "EmptyValue", "") - assert next(g) == ("AnotherSection", "Multiline", "abc\ndef\nqed\nord") + assert next(g) == ("MySection", "Value", "abc") + assert next(g) == ("MySection", "Other", "def") + assert next(g) == ("MySection", "ALLCAPS", "txt") + assert next(g) == ("AnotherSection", "EmptyValue", "") + assert next(g) == ("AnotherSection", "Multiline", "abc\ndef\nqed\nord")