repo_helper.testing

Helpers for running tests with pytest.

Attention

This module has the following additional requirements:

check-wheel-contents>=0.2.0
coincidence>=0.2.0
pytest>=6.0.0

These can be installed as follows:

python -m pip install repo-helper[testing]

New in version 2020.11.17.

Functions:

demo_environment()

Pytest fixture to create a jinja2 environment for use in tests.

example_config()

Returns the contents of the example repo_helper.yml file.

is_running_on_actions()

Returns True if running on GitHub Actions.

temp_empty_repo(tmp_pathplus, monkeypatch)

Pytest fixture to return an empty git repository in a temporary location.

temp_repo(temp_empty_repo, example_config)

Pytest fixture to return a git repository in a temporary location.

fixture demo_environment[source]

Scope:    function

Pytest fixture to create a jinja2 environment for use in tests.

The environment has the following variables available by default:

{
    "username": "octocat",
    "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 = repo_helper.files.linting.lint_warn_list.

Additional options can be set and values changed at the start of with:

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

Environment

fixture example_config[source]

Scope:    session

Returns the contents of the example repo_helper.yml file.

Return type

str

is_running_on_actions()[source]

Returns True if running on GitHub Actions.

Return type

bool

fixture temp_empty_repo[source]

Scope:    function

Pytest fixture to return an empty git repository in a temporary location.

repo_helper.utils.today is monkeypatched to return 25th July 2020.

Return type

Repo

fixture temp_repo[source]

Scope:    function

Pytest fixture to return a git repository in a temporary location.

The repository will contain a repo_helper.yml yaml file, the contents of which can be seen at https://github.com/domdfcoding/repo_helper/blob/master/repo_helper/testing/repo_helper_example.yml.

repo_helper.utils.today is monkeypatched to return 25th July 2020.

Return type

Repo