# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. #
def usage():
message = """usage: {program} [option]... [task_file]..."
-h | --help: print usage information
{connection_params}
the 'task_file' parameters should be
full absolute pathnames, not URLs."""
print(message.format(program = os.path.basename(sys.argv[0]), \
connection_params = OfficeConnection.getHelpText()))
def find_test_files(dir_path):
valid_files = [] for f in sorted(os.listdir(dir_path)):
file_path = os.path.join(dir_path, f)
# don't go through the sub-directories ifnot os.path.isfile(file_path): continue
if os.path.splitext(file_path)[1] == ".swp": continue# ignore VIM swap files
if file_path[-1:] == "~": continue# ignore backup files
# fail on any non .py files ifnot os.path.splitext(file_path)[1] == ".py": raise Exception("file with an extension which is not .py: " + file_path)
# ignore the __init__.py file # it is obviously not a test file if f == "__init__.py": continue
valid_files.append(file_path)
return valid_files
def get_classes_of_module(module):
md = module.__dict__ return [ md[c] for c in md if (
isinstance(md[c], type) and md[c].__module__ == module.__name__ ) ]
def get_test_case_classes_of_module(module):
classes = get_classes_of_module(module) return [ c for c in classes if issubclass(c, UITestCase) ]
loader = importlib.machinery.SourceFileLoader(module_name, test_file) # exec_module was only introduced in 3.4 if sys.version_info < (3,4):
mod = loader.load_module() else:
mod = types.ModuleType(loader.name)
loader.exec_module(mod)
classes = get_test_case_classes_of_module(mod) global test_name_limit_found for c in classes:
test_names = test_loader.getTestCaseNames(c) for test_name in test_names:
full_name = ".".join([module_name, c.__name__, test_name]) if len(test_name_limit) > 0: if test_name_limit != full_name: continue
test_name_limit_found = True
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.