Description: Change dotexport test to use tmpdir to fix race condition
 In the upstream package, the dotexport test manually creates and
 deletes temporary directories in a way that exposes it to possible
 race conditions. This patch corrects that by having it use the pytest
 tmpdir constructs, which handle temporary directories safely.
Author: Mitchell Augustin <mitchell@mitchellaugustin.com>
Forwarded: https://github.com/c0fec0de/anytree/pull/261

---
Origin: other, https://github.com/c0fec0de/anytree/pull/261/commits/48d366741cf18f21c0190ad2b130dea97b2d7ff6
Bug: https://github.com/c0fec0de/anytree/issues/258
Last-Update: 2024-06-13

--- anytree-2.12.1.orig/tests/test_dotexport.py
+++ anytree-2.12.1/tests/test_dotexport.py
@@ -9,22 +9,9 @@ from anytree.dotexport import RenderTree
 from .helper import with_setup
 
 TESTPATH = dirname(__file__)
-GENPATH = join(TESTPATH, "dotexport")
 REFPATH = join(TESTPATH, "refdata")
 
-
-def setup():
-    if not exists(GENPATH):
-        makedirs(GENPATH)
-
-
-def teardown():
-    if exists(GENPATH):
-        rmtree(GENPATH)
-
-
-@with_setup(setup, teardown)
-def test_tree1():
+def test_tree1(tmpdir):
     """Tree1."""
     root = Node("root")
     s0 = Node("sub0", parent=root)
@@ -36,12 +23,11 @@ def test_tree1():
     s1c = Node("sub1C", parent=s1)
     Node(99, parent=s1c)
 
-    RenderTreeGraph(root).to_dotfile(join(GENPATH, "tree1.dot"))
-    assert cmp(join(GENPATH, "tree1.dot"), join(REFPATH, "tree1.dot"))
+    RenderTreeGraph(root).to_dotfile(join(tmpdir, "tree1.dot"))
+    assert cmp(join(tmpdir, "tree1.dot"), join(REFPATH, "tree1.dot"))
 
 
-@with_setup(setup, teardown)
-def test_tree2():
+def test_tree2(tmpdir):
     """Tree2."""
     root = Node("root")
     s0 = Node("sub0", parent=root, edge=2)
@@ -67,12 +53,11 @@ def test_tree2():
         edgeattrfunc=edgeattrfunc,
     )
 
-    r.to_dotfile(join(GENPATH, "tree2.dot"))
-    assert cmp(join(GENPATH, "tree2.dot"), join(REFPATH, "tree2.dot"))
+    r.to_dotfile(join(tmpdir, "tree2.dot"))
+    assert cmp(join(tmpdir, "tree2.dot"), join(REFPATH, "tree2.dot"))
 
 
-@with_setup(setup, teardown)
-def test_tree_png():
+def test_tree_png(tmpdir):
     """Tree to png."""
     root = Node("root")
     s0 = Node("sub0", parent=root)
@@ -84,4 +69,4 @@ def test_tree_png():
     s1c = Node("sub1C", parent=s1)
     Node("sub1Ca", parent=s1c)
 
-    RenderTreeGraph(root).to_picture(join(GENPATH, "tree1.png"))
+    RenderTreeGraph(root).to_picture(join(tmpdir, "tree1.png"))
