def test_defaultConfig(self): """ If the I{config} option is not specified, the default config.plist in the source tree is used. """ options = SimOptions() self.assertEqual(options['config'], FilePath(__file__).sibling('config.plist'))
def test_configFileNotFound(self): """ If the filename given to the I{config} option is not found, L{SimOptions.parseOptions} raises a L{UsageError} indicating this. """ name = FilePath(self.mktemp()) options = SimOptions() exc = self.assertRaises(UsageError, options.parseOptions, ['--config', name.path]) self.assertEquals( str(exc), "--config %s: No such file or directory" % (name.path, ))
def test_configFileNotParseable(self): """ If the contents of the file given to the I{config} option cannot be parsed by L{ConfigParser}, L{SimOptions.parseOptions} raises a L{UsageError} indicating this. """ config = FilePath(self.mktemp()) config.setContent("some random junk") options = SimOptions() exc = self.assertRaises(UsageError, options.parseOptions, ['--config', config.path]) self.assertEquals( str(exc), "--config %s: syntax error: line 1, column 0" % (config.path, ))