def handle_default_options(options): """ Include any default options that all commands should accept here so that ManagementUtility can handle them before searching for user commands. """ if getattr(options, 'settings'): os.environ['MADMEX_SETTINGS_MODULE'] = options.settings SETTINGS.reload() setup() LOGGER.info('Settings loaded from %s.', options.settings) if getattr(options, 'pythonpath'): sys.path.insert(0, options.pythonpath) LOGGER.info('%s was added to the PYTHONPATH.', options.settings) LOGGER.debug('Default options had been handled.')
def test_configuration(self): """ Creates a new configuration file loads it and tests if a setting is loaded correctly. """ key = 'testing' value = 'setting' path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.ini') test_file = open(path, 'w+') test_file.write('[madmex]\n') test_file.write('%s=%s\n' % (key, value)) test_file.close() from madmex.configuration import ENVIRONMENT_VARIABLE SETTINGS.reload() os.environ[ENVIRONMENT_VARIABLE] = path SETTINGS.reload() self.assertEqual(value, getattr(SETTINGS, key.upper())) del os.environ[ENVIRONMENT_VARIABLE] os.remove(path)
def test_configuration(self): """ Creates a new configuration file loads it and tests if a setting is loaded correctly. """ key = 'testing' value = 'setting' path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'test.ini' ) test_file = open(path, 'w+') test_file.write('[madmex]\n') test_file.write('%s=%s\n' % (key, value)) test_file.close() from madmex.configuration import ENVIRONMENT_VARIABLE SETTINGS.reload() os.environ[ENVIRONMENT_VARIABLE] = path SETTINGS.reload() self.assertEqual(value, getattr(SETTINGS, key.upper())) del os.environ[ENVIRONMENT_VARIABLE] os.remove(path)