def test_print_environment_vars(capsys): env = { "ANSIBLE_FOO": "foo", "ANSIBLE_BAR": "bar", "ANSIBLE": None, "MOLECULE_FOO": "foo", "MOLECULE_BAR": "bar", "MOLECULE": None, } expected = """DEBUG: ANSIBLE ENVIRONMENT: ANSIBLE_BAR: bar ANSIBLE_FOO: foo DEBUG: MOLECULE ENVIRONMENT: MOLECULE_BAR: bar MOLECULE_FOO: foo DEBUG: SHELL REPLAY: ANSIBLE_BAR=bar ANSIBLE_FOO=foo MOLECULE_BAR=bar MOLECULE_FOO=foo """ with console.capture() as capture: util.print_environment_vars(env) result = strip_ansi_escape(capture.get()) assert result == expected
def test_print_matrix(capsys, _instance): with console.capture() as capture: _instance.print_matrix() result = chomp(strip_ansi_escape(capture.get())) matrix_out = """--- default: - dependency - lint - cleanup - destroy - syntax - create - prepare - converge - idempotence - side_effect - verify - cleanup - destroy foo: - dependency - lint - cleanup - destroy - syntax - create - prepare - converge - idempotence - side_effect - verify - cleanup - destroy""" assert matrix_out in result
def test_print_debug(): expected = "DEBUG: test_title:\ntest_data\n" with console.capture() as capture: util.print_debug("test_title", "test_data") result = strip_ansi_escape(capture.get()) assert result == expected