how much manual labor python can automate the next section provides another prime example regression test script mistakes happen as we've seenpython provides interfaces to variety of system servicesalong with tools for adding others example - shows some of the more commonly used system tools in action it implements simple regression test system for python scripts--it runs each in directory of python scripts with provided input and command-line argumentsand compares the output of each run to the prior run' results as suchthis script can be used as an automated testing system to catch errors introduced by changes in program source filesin big systemyou might not know when fix is really bug in disguise example - pp \system\tester\tester py ""###############################################################################test directory of python scriptspassing command-line argumentspiping in stdinand capturing stdoutstderrand exit status to detect failures and regressions from prior run outputs the subprocess module spawns and controls streams (much like os popen in python )and is cross-platform streams are always binary bytes in subprocess test inputsargsoutputsand errors map to files in subdirectories this is command-line scriptusing command-line arguments for optional test directory nameand force-generation flag while we could package it as callable functionthe fact that its results are messages and output files makes call/return model less useful suggested enhancementcould be extended to allow multiple sets of command-line arguments and/or inputs per test scriptto run script multiple times (glob for multiple in*files in inputs?might also seem simpler to store all test files in same directory with different extensionsbut this could grow large over time could also save both stderr and stdout to errors on failuresbut prefer to have expected/actual output in outputs on regressions ###############################################################################""import ossysglobtime from subprocess import popenpipe configuration args testdir sys argv[ if len(sys argv else os curdir forcegen len(sys argv print('start tester:'time asctime()print('in'os path abspath(testdir) regression test script