def test_app_add_options_with_raw(self): # raw option app = Application(force_args=['--option1', 'option1value', 'extraargs']) app.add_option('--option1', dest='option1') app.init() assert app.get_options().option1 == 'option1value' assert app.argv() == ['extraargs']
def test_app_registry_exit_functions(self): self.factory.new_module('first') self.factory.new_module('second', dependencies='first') self.factory.new_module('third', dependencies=['first', 'second']) app = Application(force_args=[]) app.init() app._state = app.SHUTDOWN app._run_module_teardown() assert self.factory.value('third_exit') > 0 and ( self.factory.value('second_exit') > 0 and self.factory.value('first_exit') > 0), ( 'all exit callbacks should have been called') assert self.factory.value('third_exit') < self.factory.value('second_exit') assert self.factory.value('third_exit') < self.factory.value('first_exit')
def test_app_registry_dependencies_of_list(self): self.factory.new_module('first') self.factory.new_module('second', dependencies='first') self.factory.new_module('third', dependencies=['first', 'second']) app = Application(force_args=[]) app.init() assert self.factory.value('first') > 0, 'first callback should be called' assert self.factory.value('second') > 0, 'second callback should be called' assert self.factory.value('third') > 0, 'third callback should be called' assert self.factory.value('first') < self.factory.value('third'), ( 'third callback should be called after first') assert self.factory.value('second') < self.factory.value('third'), ( 'third callback should be called after first')
def test_app_registry_basic(self): self.factory.new_module('hello') app = Application(force_args=['--app_debug']) app.init() assert self.factory.value('hello') == 1, ( 'initialization functions should be invoked on app.init')