def test_run_empty(self): program_inst = program.Program() with self.assertRaises(RuntimeError) as ctx: program_inst() self.assertEqual(pyv.get_exc_message(ctx.exception), 'No suites or scripts for execution')
def test_register_suites(self): program_inst = program.Program() suite_inst = suite.Suite('test') program_inst.register_suites([suite_inst]) self.assertIn(suite_inst, program_inst.suites)
def setUp(self): self.base_layer = seismograph.ProgramLayer() self.program_layer = layers.ProgramLayer() self.program = program.Program() self.context = program.ProgramContext( lambda: None, lambda: None, ) self.context.add_layers([self.program_layer])
def test_init(self): program_inst = program.Program() self.assertEqual(program_inst.exit, True) self.assertEqual(program_inst.suites, []) self.assertEqual(program_inst.scripts, []) self.assertEqual(program_inst.suites_path, '__main__') self.assertIsInstance(program_inst.config, config.Config) self.assertIsInstance(program_inst.context, program.ProgramContext)
def test_register_scripts(self): program_inst = program.Program() class Script(script.Script): def task(self): pass program_inst.register_scripts([Script]) self.assertEqual(len(program_inst.scripts), 1) self.assertIsInstance(program_inst.scripts[0], Script)
class TestFullCycle(BaseTestCase): def runTest(self): case_layer = layers.CaseLayer() suite_layer = layers.SuiteLayer() program_layer = layers.ProgramLayer() suite_inst = suite.Suite('test', layers=[suite_layer]) @suite_inst.register(layers=[case_layer]) class TestOne(case.Case): def test(self): pass @suite_inst.register def simple_test(case): pass program_inst = program.Program(exit=False, stream=StringIO(), layers=[program_layer]) program_inst.register_suite(suite_inst) self.assertTrue(program_inst()) self.assertEqual( program_inst._Program__stream.getvalue(), u'Seismograph is measuring:\n\n' u'..\n\n' u'---------------------------------------------------------------\n' u'tests=2 failures=0 errors=0 skipped=0 successes=2 runtime=0.001\n' ) self.assertEqual( case_layer.calling_story, ['on_init', 'on_require', 'on_run', 'on_setup', 'on_teardown', 'on_success'], ) self.assertEqual( suite_layer.calling_story, ['on_init', 'on_require', 'on_mount', 'on_run', 'on_setup', 'on_teardown'], ) self.assertEqual( program_layer.calling_story, ['on_option_parser', 'on_config', 'on_init', 'on_run', 'on_setup', 'on_teardown'], )
def test_basic(self): program_inst = program.Program() suite_inst = suite.Suite('package.module') self.assertTrue(program_inst.suite_is_valid(suite_inst))
def test_require(self): program_inst = program.Program(require=['some_ext']) self.assertIn('some_ext', program_inst.context.require)