pystache.tests.common module

Provides test-related code that can be used by all tests.

class pystache.tests.common.AssertExceptionMixin[source]

Bases: object

A unittest.TestCase mixin adding assertException().

assertException(exception_type, msg, callable, *args, **kwds)[source]
class pystache.tests.common.AssertIsMixin[source]

Bases: object

A unittest.TestCase mixin adding assertIs().

assertIs(first, second)[source]
class pystache.tests.common.AssertStringMixin[source]

Bases: object

A unittest.TestCase mixin to check string equality.

assertString(actual, expected, format=None)[source]

Assert that the given strings are equal and have the same type.

Arguments:

format: a format string containing a single conversion specifier %s.

Defaults to “%s”.

class pystache.tests.common.Attachable(**kwargs)[source]

Bases: object

A class that attaches all constructor named parameters as attributes.

For example–

>>> obj = Attachable(foo=42, size="of the universe")
>>> repr(obj)
"Attachable(foo=42, size='of the universe')"
>>> obj.foo
42
>>> obj.size
'of the universe'
class pystache.tests.common.SetupDefaults[source]

Bases: object

Mix this class in to a unittest.TestCase for standard defaults.

This class allows for consistent test results across Python 2/3.

setup_defaults()[source]
teardown_defaults()[source]
pystache.tests.common.get_data_path(file_name=None)[source]

Return the path to a file in the test data directory.

pystache.tests.common.get_module_names(package_dir=None, should_include=None)[source]

Return a list of fully-qualified module names in the given package.

pystache.tests.common.get_spec_test_dir(project_dir)[source]
pystache.tests.common.html_escape(u)[source]

An html escape function that behaves the same in both Python 2 and 3.

This function is needed because single quotes are escaped in Python 3 (to ‘'’), but not in Python 2.

The global defaults.TAG_ESCAPE can be set to this function in the setUp() and tearDown() of unittest test cases, for example, for consistent test results.