How to use the pyscaffold.api.create_project function in PyScaffold

To help you get started, we’ve selected a few PyScaffold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / pyscaffold / tests / extensions / test_pre_commit.py View on Github external
def test_create_project_without_pre_commit(tmpfolder):
    # Given options without the pre-commit extension,
    opts = dict(project="proj")

    # when the project is created,
    create_project(opts)

    # then pre-commit files should not exist
    assert not path_exists("proj/.pre-commit-config.yaml")
    assert not path_exists("proj/.isort.cfg")
github pyscaffold / pyscaffold / tests / extensions / test_cookiecutter.py View on Github external
def test_create_project_with_cookiecutter_but_no_template(tmpfolder):
    # Given options with the cookiecutter extension, but no template
    opts = dict(
        project=PROJ_NAME, extensions=[cookiecutter.Cookiecutter("cookiecutter")]
    )

    # when the project is created,
    # then an exception should be raised.
    with pytest.raises(cookiecutter.MissingTemplate):
        create_project(opts)
github pyscaffold / pyscaffold / tests / extensions / test_tox.py View on Github external
def test_create_project_without_tox(tmpfolder):
    # Given options without the tox extension,
    opts = dict(project="proj")

    # when the project is created,
    create_project(opts)

    # then tox files should not exist
    assert not path_exists("proj/tox.ini")
github pyscaffold / pyscaffold / tests / extensions / test_travis.py View on Github external
def test_create_project_without_travis(tmpfolder):
    # Given options without the travis extension,
    opts = dict(project="proj")

    # when the project is created,
    create_project(opts)

    # then travis files should not exist
    assert not path_exists("proj/.travis.yml")
    assert not path_exists("proj/tests/travis_install.sh")
github pyscaffold / pyscaffold / tests / extensions / test_cookiecutter.py View on Github external
def test_create_project_with_cookiecutter(tmpfolder):
    # Given options with the cookiecutter extension,
    opts = dict(
        project=PROJ_NAME,
        cookiecutter=COOKIECUTTER_URL,
        extensions=[cookiecutter.Cookiecutter("cookiecutter")],
    )

    # when the project is created,
    create_project(opts)

    # then cookiecutter files should exist
    for path in COOKIECUTTER_FILES:
        assert path_exists(path)
    # and also overwritable pyscaffold files (with the exact contents)
    tmpfolder.join(PROJ_NAME).join("setup.py").read() == setup_py(opts)
github pyscaffold / pyscaffold / tests / extensions / test_namespace.py View on Github external
def test_pretend_move_old_package(tmpfolder, caplog, isolated_logger):
    # Given a package is already created without namespace
    create_project(project="proj", package="my_pkg")

    opts = parse_args(["proj", "-p", "my_pkg", "--namespace", "my.ns", "--pretend"])
    opts = process_opts(opts)
    logger.reconfigure(opts)
    struct = dict(proj={"src": {"my_pkg": {"file.py": ""}}})

    # when 'pretend' option is passed,
    struct, opts = get_default_options(struct, opts)
    struct, opts = enforce_namespace_options(struct, opts)
    struct, opts = move_old_package(struct, opts)

    # then nothing should happen,
    assert tmpfolder.join("proj/src/my_pkg/__init__.py").check()
    assert not tmpfolder.join("proj/src/my/ns").check()

    # something should be logged,
github pyscaffold / pyscaffold / tests / extensions / test_namespace.py View on Github external
def test_updating_existing_project(tmpfolder, caplog):
    # Given a project already exists, but was generated without
    # namespace,
    create_project(project="my-proj")
    assert tmpfolder.join("my-proj/src/my_proj").check()
    assert not tmpfolder.join("my-proj/src/my/ns").check()

    # when the project is updated with a namespace,
    create_project(
        project="my-proj",
        update=True,
        namespace="my.ns",
        extensions=[namespace.Namespace("namespace")],
    )

    # then the package folder should be moved to a nested position,
    assert not tmpfolder.join("my-proj/src/my_proj").check()
    assert tmpfolder.join("my-proj/src/my/ns/my_proj").check()

    # and the user should see a warn
github pyscaffold / pyscaffold / tests / test_api.py View on Github external
def test_create_project_call_extension_hooks(tmpfolder, git_mock):
    # Given an extension with hooks,
    called = []

    def pre_hook(struct, opts):
        called.append("pre_hook")
        return struct, opts

    def post_hook(struct, opts):
        called.append("post_hook")
        return struct, opts

    # when created project is called,
    create_project(project="proj", extensions=[create_extension(pre_hook, post_hook)])

    # then the hooks should also be called.
    assert "pre_hook" in called
    assert "post_hook" in called
github pyscaffold / pyscaffold / tests / test_api.py View on Github external
def test_create_project_when_folder_exists(tmpfolder, git_mock):
    tmpfolder.ensure("my-project", dir=True)
    opts = dict(project="my-project")
    with pytest.raises(DirectoryAlreadyExists):
        create_project(opts)
    opts = dict(project="my-project", force=True)
    create_project(opts)
github pyscaffold / pyscaffold / tests / extensions / test_cirrus.py View on Github external
def test_create_project_without_cirrus(tmpfolder):
    # Given options without the cirrus extension,
    opts = dict(project_path="proj")

    # when the project is created,
    create_project(opts)

    # then cirrus files should not exist
    assert not path_exists("proj/.cirrus.yml")