nose2.util

nose2.util.ensure_importable(dirname)[source]

Ensure a directory is on sys.path

nose2.util.exc_info_to_string(err, test)[source]

Format exception info for output

nose2.util.format_traceback(test, err)[source]

Converts a sys.exc_info()-style tuple of values into a string.

nose2.util.has_module_fixtures(test)[source]

Does this test live in a module with module fixtures?

nose2.util.isgenerator(obj)[source]

is this object a generator?

nose2.util.ispackage(path)[source]

Is this path a package directory?

nose2.util.ln(label, char='-', width=70)[source]

Draw a divider, with label in the middle.

>>> ln('hello there')
'---------------------------- hello there -----------------------------'

Width and divider char may be specified. Defaults are 70 and ‘-‘ respectively.

nose2.util.module_from_name(name)[source]

Import module from name

nose2.util.name_from_args(name, index, args)[source]

Create test name from test args

nose2.util.name_from_path(path)[source]

Translate path into module name

nose2.util.object_from_name(name, module=None)[source]

Import object from name

nose2.util.parse_log_level(lvl)[source]

Return numeric log level given a string

nose2.util.safe_decode(string)[source]

Safely decode a byte string into unicode

nose2.util.test_from_name(name, module)[source]

Import test from name

nose2.util.transplant_class(cls, module)[source]

Make class appear to reside in module.

Parameters:
  • cls – A class
  • module – A module name
Returns:

A subclass of cls that appears to have been defined in module.

The returned class’s __name__ will be equal to cls.__name__, and its __module__ equal to module.

nose2.util.valid_module_name(path)[source]

Is path a valid module name?