Test module: standard_parsers.py

standard_parsers.py

This module tests the argparse.ArgumentParser instance returned by standard_parsers.py with a variety of options and choices. These tests use the standard unittest package and extend the unittest.TestCase class.

module_version:1.0
created_on:2013-04-08

Standard Parser tests

class tests.standard_parsers.TestStandardArgparse(methodName='runTest')[source]

Test the function defined in standard_parsers.py.

A standard argparse.ArgumentParser instance is created from a call to standard_parser and then is tested with different sets of arguments.

setUp()[source]

Initialize the framework for testing.

Creates a new parser and creates a new system temporary directory with the tempfile package for use as an existing directory. A file called thisfileexists.txt is created in this directory as an existing file. Two new paths that do not exist, one a fake sub-directory in the existing directory and the other a fake file in this fake directory, are constructed.

tearDown()[source]

Remove testing framework.

Deletes the created temporary directory and thisfileexists.txt file.

test_standard_parser_infile()[source]

Test the parser with existing and non-existent infile arguments

Test object Expectation
Existing file Stores the filename
Non-existent file Raise SystemExit exception
test_standard_parser_log()[source]

Test the parser with existing and non-existent -l|–log arguments

Test object Expectation
Existing file Stores the filename
Non-existent file Creates the path and stores the filename
test_standard_parser_outfile()[source]

Test the parser with existing and non-existent outfile arguments

Test object Expectation
Existing file Stores the filename
Non-existent file Creates the path and stores the filename
test_standard_parser_returns()[source]

Test that the standard_parser function returns the correct objects

Test object Expectation
valid arguments Returns a argparse.ArgumentParser instance & 2 lists; 1) list of positional arguments & defaults (should be None), 2)list of keyword arguments & defaults.
test_standard_parser_tmpdir()[source]

Test the parser with existing and non-existent –tmpdir arguments

Test object Expectation
no –tmpdir Create & store a system defined temp dir
–tmpdir Create & store a system defined temp dir
–tmpdir <existing path> Store <path> as the temp dir
–tmpdir <non-existent path> Create & store <path> as the temp dir
test_standard_parser_verbosity()[source]

Test the parser with a -v|–verbose argument

Test object Expectation
no -v Stores False
-v Stores True

Table Of Contents

Previous topic

Test Routines

Next topic

Test module: custom_callables.py

This Page