def build_suite(self, loaded_module): """ loads the found tests and builds the test suite """ tag_list = [] attrs = {} loader = unittest.TestLoader() suite = OpenCafeUnittestTestSuite() loaded = LoadedTestClass(loaded_module) if self.tags: tag_list, attrs, token = self._parse_tags(self.tags) if (hasattr(loaded_module, "load_tests") and not self.supress and self.method_regex == "test_*" and self.tags is None): load_tests = getattr(loaded_module, "load_tests") suite.addTests(load_tests(loader, None, None)) return suite for class_ in loaded.get_instances(): for method_name in dir(class_): load_test_flag = False if fnmatch(method_name, self.method_regex): if not self.tags: load_test_flag = True else: load_test_flag = self._check_method( class_, method_name, tag_list, attrs, token) if load_test_flag: suite.addTest(class_(method_name)) return suite
def load_tests(loader, standard_tests, pattern): suite = OpenCafeUnittestTestSuite() tests = [ "test_format_volume_on_server", "test_mount_volume_on_server", "test_verify_volume_writability", "test_verify_volume_readability", "test_unmount_used_volume", "test_detach_unmounted_volume" ] for t in tests: suite.addTest(VolumeIntegrationSmokeTests(t)) return suite
def load_file(self): """Load a file generated by --dry_run""" suites = [] for key, value in self.file_.items(): suite = OpenCafeUnittestTestSuite() module, class_ = key.rsplit(".", 1) module = importlib.import_module(module) class_ = getattr(module, class_) for test in value: suite.addTest(class_(test)) suites.append(suite) return suites
def load_tests(loader, standard_tests, pattern): suite = OpenCafeUnittestTestSuite() tests = [ "test_format_volume_on_server", "test_mount_volume_on_server", "test_verify_volume_writability", "test_verify_volume_readability", "test_unmount_used_volume", "test_detach_unmounted_volume"] for t in tests: suite.addTest(VolumeIntegrationSmokeTests(t)) return suite
def load_file(self): """Load a file generated by --dry_run""" suites = [] for key, value in self.file_.items(): suite = OpenCafeUnittestTestSuite() module, class_ = key.rsplit(".", 1) module = importlib.import_module(module) class_ = getattr(module, class_) for test in value: suite.addTest(class_(test)) suites.append(suite) return suites
def get_suites(self): """Creates the suites for testing given the options in init""" test_suites = self.load_file() for class_ in self._get_classes(self._get_modules()): suite = OpenCafeUnittestTestSuite() for test in self._get_tests(class_): suite.addTest(class_(test)) if suite._tests: test_suites.append(suite) if self.dry_run: for suite in test_suites: for test in suite: print(test) exit(0) for suite in test_suites: suite.cafe_uuid = uuid.uuid4() return test_suites
def get_suites(self): """Creates the suites for testing given the options in init""" test_suites = self.load_file() for class_ in self._get_classes(self._get_modules()): suite = OpenCafeUnittestTestSuite() for test in self._get_tests(class_): suite.addTest(class_(test)) if suite._tests: test_suites.append(suite) if self.dry_run: for suite in test_suites: for test in suite: print(test) exit(0) for suite in test_suites: suite.cafe_uuid = uuid.uuid4() return test_suites
def load_tests(loader, standard_tests, pattern): suite = OpenCafeUnittestTestSuite() suite.addTest(VolumeAttachmentsAPISmoke("test_attach_volume_to_server")) suite.addTest( VolumeAttachmentsAPISmoke("test_list_server_volume_attachments")) suite.addTest( VolumeAttachmentsAPISmoke("test_get_volume_attachment_details")) suite.addTest(VolumeAttachmentsAPISmoke("test_volume_attachment_delete")) return suite
def load_tests(loader, standard_tests, pattern): suite = OpenCafeUnittestTestSuite() suite.addTest(VolumeAttachmentsAPISmoke("test_attach_volume_to_server")) suite.addTest( VolumeAttachmentsAPISmoke("test_list_server_volume_attachments")) suite.addTest( VolumeAttachmentsAPISmoke("test_get_volume_attachment_details")) suite.addTest(VolumeAttachmentsAPISmoke("test_volume_attachment_delete")) return suite
def build_suite(self, module_path): """ loads the found tests and builds the test suite """ tag_list = [] attrs = {} loader = unittest.TestLoader() suite = OpenCafeUnittestTestSuite() try: loaded_module = import_module(module_path) except Exception as e: sys.stderr.write("{0}\n".format("=" * 70)) sys.stderr.write( "Failed to load module '{0}'\n".format(module_path, e)) sys.stderr.write("{0}\n".format("-" * 70)) print_exc(file=sys.stderr) sys.stderr.write("{0}\n".format("-" * 70)) return if self.tags: tag_list, attrs, token = self._parse_tags(self.tags) if (hasattr(loaded_module, "load_tests") and not self.supress and not self.method_regex and self.tags is None): load_tests = getattr(loaded_module, "load_tests") suite.addTests(load_tests(loader, None, None)) return suite for class_ in self.get_classes(loaded_module): for method_name in dir(class_): if (method_name.startswith("test_") and search(self.method_regex, method_name) and (not self.tags or self._check_method( class_, method_name, tag_list, attrs, token))): suite.addTest(class_(method_name)) return suite
def build_suite(self, module_path): """ loads the found tests and builds the test suite """ tag_list = [] attrs = {} loader = unittest.TestLoader() suite = OpenCafeUnittestTestSuite() try: loaded_module = import_module(module_path) except Exception as e: sys.stderr.write("{0}\n".format("=" * 70)) sys.stderr.write("Failed to load module '{0}'\n".format( module_path, e)) sys.stderr.write("{0}\n".format("-" * 70)) print_exc(file=sys.stderr) sys.stderr.write("{0}\n".format("-" * 70)) return if self.tags: tag_list, attrs, token = self._parse_tags(self.tags) if (hasattr(loaded_module, "load_tests") and not self.supress and not self.method_regex and self.tags is None): load_tests = getattr(loaded_module, "load_tests") suite.addTests(load_tests(loader, None, None)) return suite for class_ in self.get_classes(loaded_module): for method_name in dir(class_): if (method_name.startswith("test_") and search(self.method_regex, method_name) and (not self.tags or self._check_method( class_, method_name, tag_list, attrs, token))): suite.addTest(class_(method_name)) return suite