Skip to content

Commit c6f9629

Browse files
committed
#128 test of comments
1 parent 15da3ca commit c6f9629

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/test_filewriter.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def test_spec_comment(self):
173173
if os.path.exists(testfile):
174174
os.remove(testfile)
175175
specwriter = SpecWriterCallback(filename=testfile)
176+
177+
for category in "buffered_comments comments".split():
178+
for k in "start stop descriptor event".split():
179+
o = getattr(specwriter, category)
180+
self.assertEqual(len(o[k]), 0, f"no '{k}' {category}")
176181

177182
# insert comments with every document
178183
spec_comment(
@@ -199,16 +204,33 @@ def test_spec_comment(self):
199204
msg % "after",
200205
doc=tag,
201206
writer=specwriter)
207+
208+
self.assertEqual(
209+
len(specwriter.buffered_comments['stop']),
210+
1,
211+
"last 'stop' comment buffered")
202212

203213
# since stop doc was received, this appears in the next scan
204214
spec_comment(
205215
"TESTING: Appears at END of next scan",
206216
doc="stop",
207217
writer=specwriter)
208-
write_stream(specwriter, self.db["tune_ar"])
209218

210-
pass # TODO: test the file for the comments
219+
self.assertEqual(
220+
len(specwriter.buffered_comments['stop']),
221+
2,
222+
"last end of scan comment buffered")
223+
write_stream(specwriter, self.db["tune_ar"])
211224

225+
for k in "start descriptor event".split():
226+
o = specwriter.buffered_comments
227+
self.assertEqual(len(o[k]), 0, f"no '{k}' {category}")
228+
expected = dict(start=2, stop=5, event=0, descriptor=0)
229+
for k, v in expected.items():
230+
self.assertEqual(
231+
len(specwriter.comments[k]),
232+
v,
233+
f"'{k}' comments")
212234

213235

214236
def suite(*args, **kw):

0 commit comments

Comments
 (0)