[Python-Dev] unit testing and Python regression test

Andrew Kuchling akuchlin@mems-exchange.org
Fri, 1 Dec 2000 16:34:30 -0500


On Fri, Dec 01, 2000 at 04:21:27PM -0500, Jeremy Hylton wrote:
>   - I assume setup/shutdown are equivalent to setUp/tearDown 

Correct.

>   - Is it possible to override constructor for TestScenario?

Beats me; I see no reason why you couldn't, though.

>   - Is there something equivalent to PyUnit self.assert_

Probably test_bool(), I guess: self.test_bool('self.run.is_draft()')
asserts that self.run.is_draft() will return true.  Or does
self.assert_() do something more?

>   - What does parse_args() do?
>   - What does run_scenarios() do?
>   - If I have multiple scenarios, how do I get them to run?

These 3 questions are all related, really.  At the bottom of our test
scripts, we have the following stereotyped code:

if __name__ == "__main__":
    (scenarios, options) = parse_args()
    run_scenarios (scenarios, options)

parse_args() ensures consistent arguments to test scripts; -c measures
code coverage, -v is verbose, etc.  It also looks in the __main__
module and finds all subclasses of TestScenario, so you can do:  

python test_process_run.py  # Runs all N scenarios
python test_process_run.py ProcessRunTest # Runs all cases for 1 scenario
python test_process_run.py ProcessRunTest:check_access # Runs one test case
                                                       # in one scenario class

--amk