twisted.names.test.test_examples.ExampleTestBase(object)
class documentationtwisted.names.test.test_examples
(View In Hierarchy)
Known subclasses: twisted.names.test.test_examples.DnsServiceTests, twisted.names.test.test_examples.GetHostByNameTests, twisted.names.test.test_examples.MultiReverseLookupTests, twisted.names.test.test_examples.TestDnsTests
This is a mixin which adds an example to the path, tests it, and then removes it from the path and unimports the modules which the test loaded. Test cases which test example code and documentation listings should use this.
This is done this way so that examples can live in isolated path entries, next to the documentation, replete with their own plugin packages and whatever other metadata they need. Also, example code is a rare instance of it being valid to have multiple versions of the same code in the repository at once, rather than relying on version control, because documentation will often show the progression of a single piece of code as features are added to it, and we want to test each one.
Method | setUp | Add our example directory to the path and record which modules are currently loaded. |
Method | tearDown | Remove the example directory from the path and remove all modules loaded by the test from sys.modules. |
Method | test_shebang | The example scripts start with the standard shebang line. |
Method | test_usageConsistency | The example script prints a usage message to stdout if it is passed a --help option and then exits. |
Method | test_usageConsistencyOnError | The example script prints a usage message to stderr if it is passed unrecognized command line arguments. |
Add our example directory to the path and record which modules are currently loaded.
Remove the example directory from the path and remove all modules loaded by the test from sys.modules.
The example script prints a usage message to stdout if it is passed a --help option and then exits.
The first line should contain a USAGE summary, explaining the accepted command arguments.
The example script prints a usage message to stderr if it is passed unrecognized command line arguments.
The first line should contain a USAGE summary, explaining the accepted command arguments.
The last line should contain an ERROR summary, explaining that incorrect arguments were supplied.