mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
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:
committed by
Ruslan Kuprieiev
co-authored by
David de la Iglesia Castro
parent
a3261637de
commit
3faf413288
+1
-2
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user