From 75a6c67d97a10f86c61f5fc6d7095eda5bbb3134 Mon Sep 17 00:00:00 2001 From: vdshk Date: Sun, 16 May 2021 23:06:08 +0300 Subject: [PATCH] Added tests for txt.py --- tests/graphs/readwrite/txt.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/graphs/readwrite/txt.py b/tests/graphs/readwrite/txt.py index 36041334..81619007 100644 --- a/tests/graphs/readwrite/txt.py +++ b/tests/graphs/readwrite/txt.py @@ -13,7 +13,7 @@ g1 = cfpq_data.labeled_binomial_graph(42, 0.42, seed=seed, verbose=False) g2 = cfpq_data.labeled_binomial_graph(42, 0.73, seed=seed, verbose=False) -g3 = cfpq_data.graph_from_text("1 2\n2 3", verbose=False) +g3 = cfpq_data.graph_from_text("1 2", verbose=False) @pytest.mark.parametrize( @@ -39,6 +39,29 @@ def test_txt(graph): ) +@pytest.mark.parametrize( + "graph", + [ + g1, + g2, + g3, + ], +) +def test_txt_with_quoting(graph): + (fd, fname) = tempfile.mkstemp() + + path = cfpq_data.graph_to_txt(graph, fname, quoting=True, verbose=False) + gin = cfpq_data.graph_from_txt(path, verbose=False) + + os.close(fd) + os.unlink(fname) + + assert ( + graph.number_of_nodes() == gin.number_of_nodes() + and graph.number_of_edges() == gin.number_of_edges() + ) + + @pytest.mark.parametrize( "graph", [