本文整理汇总了Python中nose.util.test_address函数的典型用法代码示例。如果您正苦于以下问题:Python test_address函数的具体用法?Python test_address怎么用?Python test_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_address函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: address
def address(self):
"""Return a round-trip name for this test, a name that can be
fed back as input to loadTestByName and (assuming the same
plugin configuration) result in the loading of this test.
"""
if self.descriptor is not None:
return test_address(self.descriptor)
else:
return test_address(self.method)
开发者ID:AlexArgus,项目名称:affiliates-lib,代码行数:9,代码来源:case.py
示例2: get_nose_name
def get_nose_name(its_self):
if isinstance(its_self, (FunctionTestCase, MethodTestCase)):
file_, module, class_ = test_address(its_self)
name = '%s:%s' % (module, class_)
return name
elif isinstance(its_self, TestModule):
return its_self.moduleName
开发者ID:ceph,项目名称:ceph-autotests,代码行数:7,代码来源:util.py
示例3: address
def address(self):
if self._nose_obj is not None:
return test_address(self._nose_obj)
obj = resolve_name(self._dt_test.name)
if isproperty(obj):
# properties have no connection to the class they are in
# so we can't just look 'em up, we have to first look up
# the class, then stick the prop on the end
parts = self._dt_test.name.split(".")
class_name = ".".join(parts[:-1])
cls = resolve_name(class_name)
base_addr = test_address(cls)
return (base_addr[0], base_addr[1], ".".join([base_addr[2], parts[-1]]))
else:
return test_address(obj)
开发者ID:Byron,项目名称:bdep-oss,代码行数:16,代码来源:doctests.py
示例4: _makeTest
def _makeTest(self, obj, parent=None):
"""Given a test object and its parent, return a test case
or test suite.
"""
plug_tests = []
try:
addr = test_address(obj)
except KeyboardInterrupt:
raise
except:
addr = None
for test in self.config.plugins.makeTest(obj, parent):
plug_tests.append(test)
# TODO: is this try/except needed?
try:
if plug_tests:
return self.suiteClass(plug_tests)
except (KeyboardInterrupt, SystemExit):
raise
except:
exc = sys.exc_info()
return Failure(exc[0], exc[1], exc[2], address=addr)
if isfunction(obj) and parent and not isinstance(parent, types.ModuleType):
# This is a Python 3.x 'unbound method'. Wrap it with its
# associated class..
obj = unbound_method(parent, obj)
if isinstance(obj, unittest.TestCase):
return obj
elif isclass(obj):
if parent and obj.__module__ != parent.__name__:
obj = transplant_class(obj, parent.__name__)
if issubclass(obj, unittest.TestCase):
return self.loadTestsFromTestCase(obj)
else:
return self.loadTestsFromTestClass(obj)
elif ismethod(obj):
if parent is None:
parent = obj.__class__
if issubclass(parent, unittest.TestCase):
return parent(obj.__name__)
else:
if isgenerator(obj):
return self.loadTestsFromGeneratorMethod(obj, parent)
else:
return MethodTestCase(obj)
elif isfunction(obj):
isgen = isgenerator(obj)
if parent and obj.__module__ != parent.__name__:
obj = transplant_func(obj, parent.__name__)
if isgen:
return self.loadTestsFromGenerator(obj, parent)
else:
return FunctionTestCase(obj)
else:
return Failure(TypeError,
"Can't make a test from %s" % obj,
address=addr)
开发者ID:alefend,项目名称:nose,代码行数:59,代码来源:loader.py
示例5: validateName
def validateName(self, testObject):
filepath, module, call = test_address(testObject)
node = self.hash_ring.get_node('%s.%s' % (module, call))
if node != self.node_id:
return False
return None
开发者ID:Jeff-Meadows,项目名称:distributed-nose,代码行数:8,代码来源:plugin.py
示例6: address
def address(self):
"""Return a round-trip name for this test, a name that can be
fed back as input to loadTestByName and (assuming the same
plugin configuration) result in the loading of this test.
"""
try:
return self.test.address()
except AttributeError:
# not a nose case
return test_address(self.test)
开发者ID:scbarber,项目名称:horriblepoems,代码行数:10,代码来源:case.py
示例7: generate
def generate(g=generator, c=testCaseClass):
try:
for test in g():
test_func, arg = (test[0], test[1:])
yield QUnitMethodTestCase(test_func, arg=arg, descriptor=g)
except KeyboardInterrupt:
raise
except:
exc = sys.exc_info()
yield Failure(exc[0], exc[1], exc[2],
address=test_address(generator))
开发者ID:DjangoBD,项目名称:django-qunit-ci,代码行数:11,代码来源:nose_plugin.py
示例8: nice_test_address
def nice_test_address(test):
if isinstance(test, nose.suite.ContextSuite):
addr = test_address(test.context)
if hasattr(test, 'error_context') and test.error_context:
addr = list(addr)
if addr[2]:
# class
addr[2] = '%s.%s' % (addr[2], test.error_context)
else:
# module
addr[2] = test.error_context
else:
addr = test_address(test)
if addr is None:
return '??'
path, module, test_path = addr
path = nice_path(path)
if test_path is None:
return path
return "%s:%s" % (path, test_path)
开发者ID:kmanalo,项目名称:nose-nicedots,代码行数:20,代码来源:plugin.py
示例9: generate
def generate(g=generator, m=module):
try:
for test in g():
test_func, arg = self.parseGeneratedTest(test)
if not callable(test_func):
test_func = getattr(m, test_func)
yield FunctionTestCase(test_func, arg=arg, descriptor=g)
except KeyboardInterrupt:
raise
except:
exc = sys.exc_info()
yield Failure(exc[0], exc[1], exc[2], address=test_address(generator))
开发者ID:eallik,项目名称:nose,代码行数:12,代码来源:loader.py
示例10: validateName
def validateName(self, testObject):
try:
_, module, call = test_address(testObject)
except TypeError:
module = 'unknown'
call = str(testObject)
node = self.hash_ring.get_node('%s.%s' % (module, call))
if node != self.node_id:
return False
return None
开发者ID:PolicyStat,项目名称:distributed-nose,代码行数:12,代码来源:plugin.py
示例11: makeTest
def makeTest(self, obj, parent=None):
try:
return self._makeTest(obj, parent)
except (KeyboardInterrupt, SystemExit):
raise
except:
exc = sys.exc_info()
try:
addr = test_address(obj)
except KeyboardInterrupt:
raise
except:
addr = None
return Failure(exc[0], exc[1], exc[2], address=addr)
开发者ID:crobinsonut,项目名称:nose,代码行数:14,代码来源:loader.py
示例12: _add_test_result
def _add_test_result(self, test, status, output, err=None):
filename, module, _ = test_address(test)
if filename and (filename.endswith('.pyc') or
filename.endswith('.pyo')):
filename = filename[:-1]
name = str(test)
fixture = module or test.id()
description = test.shortDescription() or ''
case = xmlio.Element('test', file=filename, name=name, fixture=fixture,
status=status)
if description:
case.append(xmlio.Element('description')[description])
if output:
case.append(xmlio.Element('stdout')[output])
if err is not None:
tb = traceback.format_exception(*err)
case.append(xmlio.Element('traceback')[tb])
self.dom.append(case)
开发者ID:stephenemslie,项目名称:bittenextranose,代码行数:18,代码来源:plugnose.py
示例13: address
def address(self, case):
if hasattr(case, 'address'):
file, mod, call = case.address()
elif hasattr(case, 'context'):
file, mod, call = test_address(case.context)
else:
raise Exception("Unable to convert %s to address" % case)
parts = []
if file is None:
if mod is None:
raise Exception("Unaddressable case %s" % case)
else:
parts.append(mod)
else:
parts.append(file)
if call is not None:
parts.append(call)
return ':'.join(map(str, parts))
开发者ID:LucianU,项目名称:kuma-lib,代码行数:18,代码来源:multiprocess.py
示例14: match
def match(self, test, test_name):
adr_file, adr_mod, adr_tst = test_address(test)
chk_file, chk_mod, chk_tst = split_test_name(test_name)
if chk_file is not None and not adr_file.startswith(chk_file):
return False
if chk_mod is not None and not adr_mod.startswith(chk_mod):
return False
if chk_tst is not None and chk_tst != adr_tst:
# could be a test like Class.test and a check like Class
if not '.' in chk_tst:
try:
cls, mth = adr_tst.split('.')
except ValueError:
return False
if cls != chk_tst:
return False
else:
return False
return True
开发者ID:thraxil,项目名称:gtreed,代码行数:20,代码来源:missed.py
示例15: address
def address(case):
if hasattr(case, "address"):
file, mod, call = case.address()
elif hasattr(case, "context"):
file, mod, call = test_address(case.context)
else:
raise Exception("Unable to convert %s to address" % case)
parts = []
if file is None:
if mod is None:
raise Exception("Unaddressable case %s" % case)
else:
parts.append(mod)
else:
# strip __init__.py(c) from end of file part
# if present, having it there confuses loader
dirname, basename = os.path.split(file)
if basename.startswith("__init__"):
file = dirname
parts.append(file)
if call is not None:
parts.append(call)
return ":".join(map(str, parts))
开发者ID:Praveen-Ramanujam,项目名称:MobRAVE,代码行数:23,代码来源:multiprocess.py
示例16: address
def address(self):
return test_address(self.context)
开发者ID:rupenp,项目名称:python-nlg,代码行数:2,代码来源:doctests.py
示例17: address
def address(self):
if self._nose_obj is not None:
return test_address(self._nose_obj)
return test_address(resolve_name(self._dt_test.name))
开发者ID:scbarber,项目名称:horriblepoems,代码行数:4,代码来源:doctests.py
示例18: afterTest
def afterTest(self, test):
self.data['result.tests'].append(test_address(test))
开发者ID:dchin,项目名称:nose-achievements,代码行数:2,代码来源:plugin.py
示例19: addFailure
def addFailure(self, test, err):
type_, value, traceback = err
exc_string = "".join(format_exception(type_, value, traceback))
self.data['result.string'] += 'F'
self.data['result.failures'].append((test_address(test),
(type_, value, exc_string)))
开发者ID:dchin,项目名称:nose-achievements,代码行数:6,代码来源:plugin.py
示例20: id
def id(self):
base = '.'.join([x for x in test_address(self.context)[1:] if x])
if self.error_context == 'teardown':
return '%s:%s' % (base, self.error_context)
return base
开发者ID:jonozzz,项目名称:nose,代码行数:5,代码来源:suite.py
注:本文中的nose.util.test_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论