c7n.testing module

class c7n.testing.TestUtils(methodName='runTest')[source]

Bases: unittest.case.TestCase

capture_logging(name=None, level=20, formatter=None, log_file=None)[source]
change_cwd(work_dir=None)[source]
change_environment(**kwargs)[source]

Change the environment to the given set of variables.

To clear an environment variable set it to None. Existing environment restored after test.

cleanUp()[source]
custodian_schema = None
get_context(config=None, session_factory=None, policy=None)[source]
get_temp_dir()[source]

Return a temporary directory that will get cleaned up.

load_policy(data, config=None, session_factory=None, validate=False, output_dir=None, cache=False)[source]
load_policy_set(data, config=None)[source]
patch(obj, attr, new)[source]
tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

write_policy_file(policy, format='yaml')[source]

Write a policy file to disk in the specified format.

Input a dictionary and a format. Valid formats are yaml and json Returns the file path.

class c7n.testing.TextTestIO[source]

Bases: _io.StringIO

write(b)[source]

Write string to file.

Returns the number of characters written, which is always equal to the length of the string.

c7n.testing.functional(func)
c7n.testing.mock_datetime_now(tgt, dt)[source]