mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-06 22:07:19 +02:00
80 lines
2.3 KiB
Diff
80 lines
2.3 KiB
Diff
From 48d366741cf18f21c0190ad2b130dea97b2d7ff6 Mon Sep 17 00:00:00 2001
|
|
From: Natanael Copa <ncopa@alpinelinux.org>
|
|
Date: Tue, 2 Apr 2024 10:50:03 +0200
|
|
Subject: [PATCH] tests: use tmpdir fixture to avoid race
|
|
|
|
This solves failure with pytest 8.
|
|
|
|
ref: https://docs.pytest.org/en/6.2.x/tmpdir.html
|
|
fixes: https://github.com/c0fec0de/anytree/issues/258
|
|
---
|
|
tests/test_dotexport.py | 30 ++++++++----------------------
|
|
1 file changed, 8 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/tests/test_dotexport.py b/tests/test_dotexport.py
|
|
index 9883e90..00f63da 100644
|
|
--- a/tests/test_dotexport.py
|
|
+++ b/tests/test_dotexport.py
|
|
@@ -9,22 +9,10 @@
|
|
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 +24,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 +54,11 @@ def edgeattrfunc(node, child):
|
|
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 +70,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"))
|