def test_not_class(self): t, m, starter = process_starter.get_class( 'tests.test_process_starter.main_function') self.assertEqual(t, types.FunctionType) self.assertIsInstance(m, types.FunctionType) self.assertNotIsInstance(m, class_types) self.assertIsNone(starter)
def _construct_trees_from_context(self): trees = dict() for tree_name, context_entry in self.CONTEXT.iteritems(): _, tree_klass, _ = get_class(context_entry.tree_classname) tree = tree_klass(*context_entry.enclosed_processes, full_name=tree_name, mx_name=context_entry.mx_name, mx_page=context_entry.mx_page) trees[tree_name] = tree return trees
def test_starter_method(self): t, m, starter = process_starter.get_class('tests.test_process_starter.NewClass.starter_method') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertEqual(starter, 'starter_method') self.assertIsInstance(getattr(m(), starter), types.MethodType) if PY2: self.assertIsInstance(getattr(m, starter), types.MethodType) if PY3: self.assertIsInstance(getattr(m, starter), types.FunctionType)
def test_starter_method(self): t, m, starter = process_starter.get_class( 'tests.test_process_starter.NewClass.starter_method') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertEqual(starter, 'starter_method') self.assertIsInstance(getattr(m(), starter), types.MethodType) if PY2: self.assertIsInstance(getattr(m, starter), types.MethodType) if PY3: self.assertIsInstance(getattr(m, starter), types.FunctionType)
def test_not_class(self): t, m, starter = process_starter.get_class('tests.test_process_starter.main_function') self.assertEqual(t, types.FunctionType) self.assertIsInstance(m, types.FunctionType) self.assertNotIsInstance(m, class_types) self.assertIsNone(starter)
def test_old_class_method(self): t, m, starter = process_starter.get_class('tests.test_process_starter.OldClass.starter_method') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertEqual(starter, 'starter_method')
def test_type_new_class(self): t, m, starter = process_starter.get_class('tests.test_process_starter.NewClass') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertIsNone(starter)
def test_old_class_method(self): t, m, starter = process_starter.get_class( 'tests.test_process_starter.OldClass.starter_method') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertEqual(starter, 'starter_method')
def test_type_new_class(self): t, m, starter = process_starter.get_class( 'tests.test_process_starter.NewClass') self.assertIn(t, class_types) self.assertIsInstance(m, class_types) self.assertIsNone(starter)