def test_out(capsys): log = logger.get_logger(__name__) log.out('foo') stdout, _ = capsys.readouterr() assert ' foo\n' == stdout
def test_info(capsys): log = logger.get_logger(__name__) log.info('foo') stdout, _ = capsys.readouterr() print('--> {}{}{}'.format(colorama.Fore.CYAN, 'foo'.rstrip(), colorama.Style.RESET_ALL)) x, _ = capsys.readouterr() assert x == stdout
def test_success(capsys): log = logger.get_logger(__name__) log.success('foo') stdout, _ = capsys.readouterr() print('{}{}{}'.format(colorama.Fore.GREEN, 'foo'.rstrip(), colorama.Style.RESET_ALL)) x, _ = capsys.readouterr() assert x == stdout
def test_critical(capsys): log = logger.get_logger(__name__) log.critical('foo') _, stderr = capsys.readouterr() print( '{}ERROR: {}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), colorama.Style.RESET_ALL), file=sys.stderr) _, x = capsys.readouterr() assert x in stderr
# all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from molecule import logger from molecule.driver import base from molecule import util LOG = logger.get_logger(__name__) class Ec2(base.Base): """ The class responsible for managing `EC2`_ instances. `EC2`_ is `not` the default driver used in Molecule. Molecule leverages Ansible's `ec2_module`_, by mapping variables from `molecule.yml` into `create.yml` and `destroy.yml`. .. _`ec2_module`: http://docs.ansible.com/ansible/latest/ec2_module.html .. code-block:: yaml driver:
from molecule.driver import gce from molecule.driver import linode from molecule.driver import lxc from molecule.driver import lxd from molecule.driver import openstack from molecule.driver import podman from molecule.driver import vagrant from molecule.lint import yamllint from molecule.model import schema_v2 from molecule.provisioner import ansible from molecule.verifier import ansible as ansible_verifier from molecule.verifier import goss from molecule.verifier import inspec from molecule.verifier import testinfra LOG = logger.get_logger(__name__) MOLECULE_DEBUG = boolean(os.environ.get('MOLECULE_DEBUG', 'False')) MOLECULE_DIRECTORY = 'molecule' MOLECULE_FILE = 'molecule.yml' MERGE_STRATEGY = anyconfig.MS_DICTS MOLECULE_KEEP_STRING = 'MOLECULE_' # https://stackoverflow.com/questions/16017397/injecting-function-call-after-init-with-decorator # noqa class NewInitCaller(type): def __call__(cls, *args, **kwargs): obj = type.__call__(cls, *args, **kwargs) obj.after_init() return obj
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. """Base Dependency Module.""" import abc import os import time from molecule import constants, util from molecule.logger import get_logger LOG = get_logger(__name__) class Base(object): """Dependency Base Class.""" __metaclass__ = abc.ABCMeta RETRY = 3 SLEEP = 3 BACKOFF = 3 def __init__(self, config): """ Initialize code for all :ref:`Dependency` classes.