Use sorted output in test since order is not deterministic.

Co-authored-by: David de la Iglesia Castro <[email protected]>
This commit is contained in:
Karthikeyan Singaravelan
2022-05-11 18:40:21 +03:00
committed by Ruslan Kuprieiev
co-authored by David de la Iglesia Castro
parent a3261637de
commit 3faf413288
2 changed files with 23 additions and 17 deletions
+1 -2
View File
@@ -23,9 +23,8 @@ def _show_dot(G):
from networkx.drawing.nx_pydot import write_dot
G = G.reverse()
dot_file = io.StringIO()
write_dot(G, dot_file)
write_dot(G.reverse(), dot_file)
return dot_file.getvalue()
+22 -15
View File
@@ -135,22 +135,29 @@ def test_show_ascii(repo):
def test_show_dot(repo):
assert _show_dot(repo.index.graph) == (
"strict digraph {\n"
"stage;\n"
"stage;\n"
"stage;\n"
"stage;\n"
"stage;\n"
"stage;\n"
"\"stage: 'b.dvc'\" -> \"stage: '2'\";\n"
"\"stage: 'b.dvc'\" -> \"stage: '3'\";\n"
"\"stage: 'a.dvc'\" -> \"stage: '1'\";\n"
"\"stage: 'a.dvc'\" -> \"stage: '3'\";\n"
"\"stage: 'a.dvc'\" -> \"stage: '4'\";\n"
"\"stage: '3'\" -> \"stage: '4'\";\n"
"}\n"
# dot file rendering is not deterministic though graph
# output doesn't depend upon order of lines. Use sorted values
# https://github.com/iterative/dvc/pull/7725
expected = [
"\"stage: '3'\" -> \"stage: '4'\";",
"\"stage: 'a.dvc'\" -> \"stage: '1'\";",
"\"stage: 'a.dvc'\" -> \"stage: '3'\";",
"\"stage: 'a.dvc'\" -> \"stage: '4'\";",
"\"stage: 'b.dvc'\" -> \"stage: '2'\";",
"\"stage: 'b.dvc'\" -> \"stage: '3'\";",
"stage;",
"stage;",
"stage;",
"stage;",
"stage;",
"stage;",
"strict digraph {",
"}",
]
actual = sorted(
line.rstrip() for line in _show_dot(repo.index.graph).splitlines()
)
assert actual == expected
def test_show_mermaid(repo):