]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use tmp_path fixture in test_parse_ini()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 1 Sep 2023 09:43:57 +0000 (11:43 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 1 Sep 2023 10:14:33 +0000 (12:14 +0200)
tests/test_config.py

index 2a70ae3002a66930420a3115aee5354a575cb2d9..d68716ea3232c446ab7dde9049e6045fcf18d700 100644 (file)
@@ -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")