Skip to content

Commit ed5af4f

Browse files
petercorkeclaude
andcommitted
tests: the verbose message of add_vertex
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 6375ba7 commit ed5af4f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎tests/test_vertex_init.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
still seen.
88
"""
99

10+
import contextlib
11+
import io
1012
import unittest
1113

1214
import numpy as np
@@ -99,6 +101,17 @@ def test_a_vertex_in_a_graph_cannot_be_added_to_another(self):
99101
with self.assertRaises(ValueError):
100102
h.add_vertex(v)
101103

104+
def test_a_verbose_graph_says_what_it_adds(self):
105+
g = UGraph(dim=2, verbose=True)
106+
buf = io.StringIO()
107+
with contextlib.redirect_stdout(buf):
108+
g.add_vertex([1.0, 2.0], name="a")
109+
g.add_vertex([3.0, 4.0])
110+
lines = buf.getvalue().splitlines()
111+
self.assertEqual(len(lines), 2)
112+
self.assertTrue(lines[0].startswith("New vertex a: "))
113+
self.assertTrue(lines[1].startswith("New vertex #1: "))
114+
102115
def test_assigning_a_coordinate_is_still_seen(self):
103116
g = UGraph(dim=2)
104117
v = g.add_vertex([0.0, 0.0])

0 commit comments

Comments
 (0)