Bingo! Intercepting the output from unittest does the trick. And I have to diddle that output anyway to neutralize the displayed time since the test run times would vary between users. Here's my quick hack:
if __name__ == '__main__':It needs re-packaging into a more useful form. What's a bit curious is that it redirects stdout (also works with stderr), but it works.
# find all tests in this module
suite = unittest.TestLoader().loadTestsFromModule(__main__)
with io.StringIO() as buf:
# run the tests
# process the results - neutralise the time taken
# since this can vary depending on the phases of the moon
result = buf.getvalue()
start = result.find(' in ') + len(' in ')
end = result.find('s', start, len(result))
result = result.replace(result[start:end], 'X.XXX')
Thanks a bunch for your quick and insightful help!