MCPcopy Create free account
hub / github.com/ActiveState/code / test2

Function test2

recipes/Python/361168_Vpython_example/recipe-361168.py:262–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260 a.quit()
261
262def test2():
263 from StringIO import StringIO
264 oldStdin = sys.stdin
265 testInput = '\n'.join([
266 '10',
267 'move 9 onto 1',
268 'move 8 over 1',
269 'move 7 over 1',
270 'move 6 over 1',
271 'pile 8 over 6',
272 'pile 8 over 5',
273 'move 2 over 1',
274 'move 4 over 9',
275 'pile 9 onto 7',
276 'pile 9 onto 1',
277 'quit',
278 ''])
279 sys.stdin = StringIO(testInput)
280 oldStdout = sys.stdout
281 sys.stdout = s = StringIO()
282 parse()
283 sys.stdin = oldStdin
284 sys.stdout = oldStdout
285 reqd = '\n'.join([
286 ' 0: 0',
287 ' 1: 1 9 2 4',
288 ' 2: ',
289 ' 3: 3',
290 ' 4: ',
291 ' 5: 5 8 7 6',
292 ' 6: ',
293 ' 7: ',
294 ' 8: ',
295 ' 9: ',
296 ''])
297 s = s.getvalue()
298 if s != reqd:
299 print repr(s)
300 print repr(reqd)
301 else:
302 print 'OK'
303 sys.exit()
304
305if __name__ == '__main__':
306 test2()

Callers 1

recipe-361168.pyFile · 0.70

Calls 5

StringIOFunction · 0.90
parseFunction · 0.70
joinMethod · 0.45
getvalueMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected