How to use the pyscaffold.cli.parse_args 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 / test_info.py View on Github external
def test_project_without_args(tmpfolder):
    old_args = [
        "my_project",
        "-u",
        "http://www.blue-yonder.com/",
        "-d",
        "my description",
    ]
    cli.main(old_args)
    args = ["my_project"]
    opts = cli.parse_args(args)
    opts = cli.process_opts(opts)
    new_opts = info.project(opts)
    assert new_opts["url"] == "http://www.blue-yonder.com/"
    assert new_opts["package"] == "my_project"
    assert new_opts["license"] == "mit"
    assert new_opts["description"] == "my description"
github pyscaffold / pyscaffold / tests / test_cli.py View on Github external
def test_parse_list_actions():
    opts = cli.parse_args(["my-project", "--list-actions"])
    assert opts["command"] == cli.list_actions
    opts = cli.parse_args(["my-project"])
    assert opts["command"] == cli.run_scaffold
github pyscaffold / pyscaffold / tests / test_info.py View on Github external
def test_project_with_no_setup(tmpfolder):
    os.mkdir("my_project")
    args = ["my_project"]
    opts = cli.parse_args(args)
    opts = cli.process_opts(opts)
    with pytest.raises(FileNotFoundError):
        info.project(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,
    log = caplog.text
    expected_log = ("move", "my_pkg", "to", str(Path("my/ns")))
github pyscaffold / pyscaffold / tests / test_cli.py View on Github external
def test_parse_default_log_level():
    args = ["my-project"]
    opts = cli.parse_args(args)
    assert opts["log_level"] == logging.WARNING
github pyscaffold / pyscaffold / tests / extensions / test_namespace.py View on Github external
def test_add_namespace():
    args = ["project", "-p", "package", "--namespace", "com.blue_yonder"]
    opts = parse_args(args)
    opts = process_opts(opts)
    opts["ns_list"] = prepare_namespace(opts["namespace"])
    struct = {"project": {"src": {"package": {"file1": "Content"}}}}
    ns_struct, _ = add_namespace(struct, opts)
    ns_pkg_struct = ns_struct["project"]["src"]
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_pkg_struct.keys())
    assert {"blue_yonder", "__init__.py"} == set(ns_pkg_struct["com"].keys())
    assert "package" in list(ns_pkg_struct["com"]["blue_yonder"].keys())
github pyscaffold / pyscaffoldext-markdown / tests / test_custom_extension.py View on Github external
def test_generated_extension_flake8(tmpfolder, venv_run):
    args = [EXT_FLAG, "my_project"]
    opts = parse_args(args)
    opts = process_opts(opts)
    create_project(opts)

    with chdir("my_project"):
        assert "" == venv_run("flake8")
        venv_run("python setup.py install")

    venv_run("putup {ext_flag} the_actual_project".format(ext_flag=EXT_FLAG))
    assert path_exists("the_actual_project/setup.cfg")

    with chdir("the_actual_project"):
        assert "" == venv_run("flake8")
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_version_of_subdir(tmpfolder):
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        opts = cli.process_opts(opts)
        _, opts = api.get_default_options({}, opts)
        struct, _ = structure.define_structure({}, opts)
        struct, _ = update.apply_update_rules(struct, opts)
        structure.create_structure(struct, {})
        repo.init_commit_repo(project, struct)
    utils.rm_rf(os.path.join("inner_project", ".git"))
    shutil.move("inner_project", "main_project/inner_project")
    with utils.chdir("main_project"):
        main_version = (
            subprocess.check_output([sys.executable, "setup.py", "--version"])
            .strip()
            .splitlines()[-1]
        )
        with utils.chdir("inner_project"):
            inner_version = (
github pyscaffold / pyscaffold / tests / test_structure.py View on Github external
def test_define_structure():
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    _, opts = api.get_default_options({}, opts)
    struct, _ = structure.define_structure({}, opts)
    assert isinstance(struct, dict)
github pyscaffold / pyscaffoldext-markdown / tests / test_custom_extension.py View on Github external
def test_add_custom_extension(tmpfolder):
    args = [EXT_FLAG, "my_project", "-p", "my_package"]
    opts = parse_args(args)
    opts = process_opts(opts)
    create_project(opts)

    assert path_exists("my_project/src/my_package/__init__.py")