# HG changeset patch # User Jeff Hammel # Date 1332795283 25200 # Node ID cadc9514f60a698d28456b70ed36bc02c2fdabaf # Parent d8871956536e712ca5934d1e09a2a60d1c8a72af we have a legitimately failing test! diff -r d8871956536e -r cadc9514f60a configuration/config.py --- a/configuration/config.py Mon Mar 26 13:19:55 2012 -0700 +++ b/configuration/config.py Mon Mar 26 13:54:43 2012 -0700 @@ -121,3 +121,14 @@ parser = optparse.OptionParser(**parser_args) self.optparse_options(parser) return parser + + def parse(self, args=sys.argv[1:], parser=None): + """parse configuration including command line options""" + + # parse arguments + if parser is None: + parser = self.parser() + options, args = parser.parse_args(args) + + # return parsed arguments + return options, args diff -r d8871956536e -r cadc9514f60a tests/example.py --- a/tests/example.py Mon Mar 26 13:19:55 2012 -0700 +++ b/tests/example.py Mon Mar 26 13:54:43 2012 -0700 @@ -10,9 +10,11 @@ 'title': {'help': 'talos run title'}, 'browser_path': {'required': True, 'flags': ['-e', '--executablePath'], - 'help': 'path to firefox'} + 'help': 'path to firefox'}, + 'develop': {'help': "useful for running tests on a developer machine. Creates a local webserver and doesn't upload to the graph servers.", + 'type': bool} } if __name__ == '__main__': - parser = ExampleConfiguration().parser() - parser.parse_args() + options, args = ExampleConfiguration().parse() + diff -r d8871956536e -r cadc9514f60a tests/unit.py --- a/tests/unit.py Mon Mar 26 13:19:55 2012 -0700 +++ b/tests/unit.py Mon Mar 26 13:54:43 2012 -0700 @@ -8,7 +8,7 @@ import sys import unittest -import example # example configuration to test +from example import ExampleConfiguration # example configuration to test # globals here = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,12 @@ class configurationUnitTest(unittest.TestCase): def test_configuration(self): - + example = ExampleConfiguration() + + # parse command line arguments + options, args = example.parse(['-a', 'ts', '--develop', '-e', '/home/jhammel/bin/firefox']) + self.assertEqual(bool(args), False) # no arguments + self.assertEqual(options.develop, True) if __name__ == '__main__': unittest.main()