A module containing tests for the standard argparser custom callables I’m using in custom_callables.py. These tests use the standard unittest package and extend the unittest.TestCase class.
module_version: | 1.0 |
---|---|
created_on: | 2013-04-08 |
Test the function defined in custom_callables.py.
Each function is tested with existing and non-existent instances of the file or path type that it is designed for. We also test that providing non- string basic python objects produces string representations and doesn’t case a failure.
Initialize the framework for testing.
Define and create 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.
Remove testing framework.
Deletes the created temporary directory and thisfileexists.txt file.
Test the input_file function.
Test object | Expectation |
---|---|
Existing file | Return full file path |
Non-existent file | Raise argparse.ArgumentTypeError exception |
Non-string arg | Raise TypeError exception |
Test the input_path function.
Test object | Expectation |
---|---|
Existing path | Return full path |
Non-existent path | Raise argparse.ArgumentTypeError exception |
Non-string arg | Raise TypeError exception |