def test_valid_json_config_file(valid_json_file_with_job_name):
    """Verify that config files that contain valid JSON are not rejected.

    Args:
        valid_json_file_with_job_name (str): Path to config file.
    """

    # Test
    _load_config_file(valid_json_file_with_job_name)
def test_invalid_config_file_path():
    """Verify that an invalid config file path is rejected."""

    # Expect
    error_msg = 'Failed to load'

    # Test
    with pytest.raises(Exit) as e:
        _load_config_file('/path/does/not/exist')

    assert error_msg in str(e)
def test_invalid_json_config_file(invalid_json_file):
    """Verify that config files that do not contain valid JSON are rejected.

    Args:
        invalid_json_file (str): Path to config file.
    """

    # Expect
    error_msg = 'file is not valid JSON'

    # Test
    with pytest.raises(Exit) as e:
        _load_config_file(invalid_json_file)

    assert error_msg in str(e)
def test_invalid_config_file(invalid_pytest_zigzag_json_config):
    """Verify that config files that do not comply with the schema are rejected.

    Args:
        invalid_pytest_zigzag_json_config (str): Path to config file.
    """

    # Expect
    error_msg = 'does not comply with schema:'

    # Test
    with pytest.raises(Exit) as e:
        _load_config_file(invalid_pytest_zigzag_json_config)

    assert error_msg in str(e)
def test_valid_json_config_file_string(valid_json_file_with_job_name):
    """Verify that config files can be customized.

    Args:
        valid_json_file_with_job_name(str): Path to config file.
    """

    # Test
    config_dict = _load_config_file(valid_json_file_with_job_name)

    assert config_dict['pytest_zigzag_env_vars']['JOB_NAME'] == "foo"
Пример #6
0
# ======================================================================================================================
# Imports
# ======================================================================================================================
from __future__ import absolute_import
import os
# noinspection PyProtectedMember
from pytest_zigzag import _load_config_file
from pkg_resources import resource_stream
from tests.conftest import is_sub_dict, run_and_parse, build_property_list

# ======================================================================================================================
# Globals
# ======================================================================================================================
config_file_path = resource_stream('pytest_zigzag', 'data/configs/default-config.json').name
ASC_TEST_ENV_VARS = build_property_list(_load_config_file(config_file_path))  # Shallow copy.

# ======================================================================================================================
# Tests
# ======================================================================================================================


def test_no_env_vars_set(testdir, undecorated_test_function, testsuite_attribs_exp, simple_test_config):
    """Verify that pytest accepts our fixture without setting any environment variables."""

    # Setup
    testdir.makepyfile(undecorated_test_function.format(test_name='test_pass'))

    args = ["--pytest-zigzag-config", simple_test_config]
    junit_xml = run_and_parse(testdir, 0, args)[0]