Example #1
0
 def test_app_add_options_with_Option(self):
     # options.Option
     opt = options.Option('--option1', dest='option1')
     app.add_option(opt)
     app.init(force_args=['--option1', 'option1value', 'extraargs'])
     assert app.get_options().option1 == 'option1value'
     assert app.argv() == ['extraargs']
Example #2
0
 def test_app_add_options_with_Option(self):
   # options.Option
   opt = options.Option('--option1', dest='option1')
   app.add_option(opt)
   app.init(force_args=['--option1', 'option1value', 'extraargs'])
   assert app.get_options().option1 == 'option1value'
   assert app.argv() == ['extraargs']
Example #3
0
 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.init(force_args=[])
   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'
Example #4
0
 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.init(force_args=[])
   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'
Example #5
0
 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.init(force_args=[])
   app.quit(None, exit_function=sys.stdout.write)
   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')
Example #6
0
 def test_app_name(self):
     # This is going to be pytest as long as we invoke all these with
     # sys.interpreter -m pytest <source> since the __entry_point__ will
     # be detected as something like:
     # $HOME/workspace/science/3rdparty/python/pytest-2.0.2-py2.6.egg/pytest.pyc
     # or $HOME/.python-eggs/pants.pex/pytest-.../pytest.pyc
     assert app.name() == 'pytest'
     ALTERNATE_NAME = 'not_test_app_but_something_else'
     app.set_name(ALTERNATE_NAME)
     assert app.name() == ALTERNATE_NAME
     app.init(force_args=[])
     with pytest.raises(app.ApplicationError):
         app.set_name('anything')
Example #7
0
 def test_app_name(self):
   # This is going to be pytest as long as we invoke all these with
   # sys.interpreter -m pytest <source> since the __entry_point__ will
   # be detected as something like:
   # $HOME/workspace/science/3rdparty/python/pytest-2.0.2-py2.6.egg/pytest.pyc
   # or $HOME/.python-eggs/pants.pex/pytest-.../pytest.pyc
   assert app.name() == 'pytest'
   ALTERNATE_NAME = 'not_test_app_but_something_else'
   app.set_name(ALTERNATE_NAME)
   assert app.name() == ALTERNATE_NAME
   app.init(force_args=[])
   with pytest.raises(app.ApplicationError):
     app.set_name('anything')
Example #8
0
 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.init(force_args=[])
   def exit_function(*args):
     pass
   app.quit(None, exit_function=exit_function)
   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')
Example #9
0
 def test_app_registry_basic(self):
     self.factory.new_module('hello')
     app.init(force_args=['--app_debug'])
     assert self.factory.value(
         'hello'
     ) == 1, 'initialization functions should be invoked on app.init'
Example #10
0
 def test_app_registry_basic(self):
   self.factory.new_module('hello')
   app.init(force_args=['--app_debug'])
   assert self.factory.value('hello') == 1, 'initialization functions should be invoked on app.init'