Example #1
0
    class FakeActionsManager:

        templates = SimpleNamespace()
        templates.globals = {
            "python_versions": py_versions,
            "tox_py_versions": get_tox_python_versions(python_versions),
            "third_party_version_matrix": {},
        }

        get_gh_actions_python_versions = ActionsManager.get_gh_actions_python_versions
        get_gh_actions_matrix = ActionsManager.get_gh_actions_matrix
Example #2
0
def test_make_github_linux_case_4(
    tmp_pathplus: PathPlus,
    advanced_file_regression: AdvancedFileRegressionFixture,
    demo_environment,
    advanced_data_regression: AdvancedDataRegressionFixture,
):

    demo_environment.globals["platforms"] = ["Linux"]
    demo_environment.globals["travis_ubuntu_version"] = "bionic"
    demo_environment.globals["github_ci_requirements"] = {
        "Linux": {
            "pre": ["sudo apt update"],
            "post": ["sudo apt install python3-gi"]
        }
    }
    demo_environment.globals["travis_additional_requirements"] = [
        "isort", "black"
    ]
    demo_environment.globals["enable_tests"] = False
    demo_environment.globals["enable_conda"] = False
    demo_environment.globals["enable_releases"] = False
    demo_environment.globals["python_versions"] = {
        "3.6": {
            "experimental": False
        },
        "3.7": {
            "experimental": False
        },
        "3.8": {
            "experimental": False
        },
        "3.9": {
            "experimental": False
        },
        "3.10-dev": {
            "experimental": False
        }
    }

    demo_environment.globals["tox_py_versions"] = get_tox_python_versions(
        demo_environment.globals["python_versions"])

    managed_files = make_github_ci(tmp_pathplus, demo_environment)
    advanced_data_regression.check(managed_files,
                                   basename="github_ci_managed_files")

    assert not (tmp_pathplus / managed_files[0]).is_file()
    assert not (tmp_pathplus / managed_files[1]).is_file()
    assert (tmp_pathplus / managed_files[2]).is_file()

    advanced_file_regression.check_file(tmp_pathplus / managed_files[2])
Example #3
0
def demo_environment() -> Environment:
    """
	Pytest fixture to create a jinja2 environment for use in tests.

	The environment has the following variables available by default:

	.. code-block:: json

		{
			"username": "******",
			"assignee": "octocat",
			"imgbot_ignore": [],
			"travis_ubuntu_version": "xenial",
			"github_ci_requirements": {"Linux": {"pre": [], "post": []}},
			"travis_additional_requirements": [],
			"conda_channels": ["conda-forge"],
			"python_versions": ["3.6", "3.7"],
			"enable_tests": true,
			"enable_conda": true,
			"enable_docs": true,
			"enable_releases": true,
			"python_deploy_version": "3.6",
			"min_py_version": "3.6",
			"modname": "hello-world",
			"repo_name": "hello-world",
			"import_name": "hello_world",
			"platforms": ["Windows"],
			"pypi_name": "hello-world",
			"py_modules": [],
			"manifest_additional": [],
			"additional_requirements_files": [],
			"source_dir": "",
			"tests_dir": "tests",
			"additional_setup_args": {},
			"setup_pre": [],
			"docs_dir": "doc-source",
			"sphinx_html_theme": "alabaster",
			"additional_ignore": ["foo", "bar", "fuzz"],
			"join_path": "os.path.join",
			"pure_python": true,
			"stubs_package": false,
			"managed_message": "This file is managed by 'repo_helper'. Don't edit it directly.",
			"short_desc": "a short description",
			"on_pypi": true,
			"docs_fail_on_warning": false,
			"requires_python": "3.6.1",
			"third_party_version_matrix": {}
			}

	plus ``lint_warn_list`` = :py:data:`repo_helper.files.linting.lint_warn_list`.

	Additional options can be set and values changed at the start of tests as follows:

	.. code-block:: python

		def test(demo_environment):
			demo_environment.templates.globals["source_dir"] = "src"
	"""

    templates = Environment(  # nosec: B701
        loader=jinja2.FileSystemLoader(str(template_dir)),
        undefined=jinja2.StrictUndefined,
    )

    templates.globals.update(
        dict(
            username="******",
            assignee="octocat",
            imgbot_ignore=[],
            travis_ubuntu_version="xenial",
            github_ci_requirements={"Linux": {
                "pre": [],
                "post": []
            }},
            travis_additional_requirements=[],
            conda_channels=["conda-forge"],
            python_versions={
                "3.6": {
                    "experimental": False
                },
                "3.7": {
                    "experimental": False
                }
            },
            enable_tests=True,
            enable_conda=True,
            enable_docs=True,
            enable_releases=True,
            python_deploy_version="3.6",
            requires_python="3.6.1",
            min_py_version="3.6",
            modname="hello-world",
            repo_name="hello-world",
            docs_url="https://hello-world.readthedocs.io/en/latest",
            import_name="hello_world",
            platforms=["Windows"],
            pypi_name="hello-world",
            lint_warn_list=lint_warn_list,
            py_modules=[],
            manifest_additional=[],
            additional_requirements_files=[],
            source_dir='',
            tests_dir="tests",
            additional_setup_args={},
            setup_pre=[],
            docs_dir="doc-source",
            sphinx_html_theme="alabaster",
            additional_ignore=["foo", "bar", "fuzz"],
            join_path=os.path.join,
            pure_python=True,
            stubs_package=False,
            managed_message=
            "This file is managed by 'repo_helper'. Don't edit it directly.",
            short_desc="a short description",
            on_pypi=True,
            docs_fail_on_warning=False,
            brace=brace,
            third_party_version_matrix={},
            gh_actions_versions={
                "3.6": "py36, mypy",
                "3.7": "py37, build",
            },
        ))

    templates.globals["tox_py_versions"] = get_tox_python_versions(
        templates.globals["python_versions"])

    return templates
def test_get_tox_python_versions(data_regression: DataRegressionFixture,
                                 python_versions):
    data_regression.check(get_tox_python_versions(python_versions))