This module tests the logging.Logger instance returned by standard_logging.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 |
Test the functions defined in standard_logging.py.
A standard logging.Logger instance is created from a call to standard_logging and then is tested with different sets of arguments.
Initialize the framework for testing.
Creates a new system temporary directory with the tempfile package as a place to generate our test log file, and generate a name for the test log file. Also generates argparse.ArgumentParser instance from standard_parsers.py, a fake command line and arguments.
Remove testing framework.
Deletes the created temporary directory and thisfileexists.txt file.
Test for graceful fail when not given required arguments
Test object | Expectation |
---|---|
no verbose argument | Raise AttributeError |
no log argument | Raise AttributeError |
Test for open logfile & that script command-line is correctly written
Test object | Expectation |
---|---|
valid command-line arguments | Create file and write welcome message, time date and calling command line to it. |
Test for logging of parsed arguments
Test object | Expectation |
---|---|
valid command-line arguments | Log the full set of script arguments parsed byt he parser. Include defaults and make sure they are marked. |