@@ -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
214236def suite (* args , ** kw ):
0 commit comments