コード例 #1
0
ファイル: test_interactive.py プロジェクト: vladdu/pyscaffold
def test_cli(monkeypatch, tmpfolder):
    # When the user edit the contents of the file
    fake_content = """\
    myproj_path
    --name myproj
    --license gpl3
    --no-config
    # --namespace myns
    # ^  test commented options
    """
    fake_edit = tmpfolder / "pyscaffold.args"
    fake_edit.write_text(dedent(fake_content), "utf-8")
    monkeypatch.setattr("pyscaffold.shell.edit", lambda *_, **__: fake_edit)

    # Then, the options in the file should take place, not the ones given in the cli
    args = [
        "-vv",
        "--no-config",
        "--interactive",
        "myproj",
        "--no-tox",
        "--license",
        "mpl",
    ]
    cli.run(args)
    assert not (tmpfolder / "myproj").exists()
    assert (tmpfolder / "myproj_path/tox.ini").exists()
    assert (tmpfolder / "myproj_path/src/myproj/__init__.py").exists()
    license = (tmpfolder / "myproj_path/LICENSE.txt").read_text("utf-8")
    assert "GNU GENERAL PUBLIC LICENSE" in license
    assert "Version 3" in license
    # Commented options (or options that were not mentioned) should not take place
    assert not (tmpfolder / "myproj_path/src/myns").exists()
    assert not (tmpfolder / "myproj_path/.pre-commit-config.yaml").exists()
コード例 #2
0
def test_cli_with_tox(tmpfolder):
    # when the project is created with the CLI
    sys.argv = ["pyscaffold", "proj"]
    run()

    # then tox files should exist
    assert Path("proj/tox.ini").exists()
コード例 #3
0
def test_cli_without_no_pyproject(tmpfolder):
    # Given the command line without the no-pyproject option,
    # when pyscaffold runs,
    run(["--no-pyproject", "proj"])

    # then file should not exist
    assert not Path("proj/pyproject.toml").exists()
コード例 #4
0
def test_cli_with_no_pyproject_and_pretend(tmpfolder):
    # Given the command line with the no-pyproject and pretend options,
    # when pyscaffold runs,
    run(["--pretend", "--no-pyproject", "proj"])

    # then file should not exist (or the project itself)
    assert not Path("proj/pyproject.toml").exists()
    assert not Path("proj").exists()
コード例 #5
0
ファイル: test_cirrus.py プロジェクト: vladdu/pyscaffold
def test_cli_without_cirrus(tmpfolder):
    # Given the command line without the cirrus option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then cirrus files should not exist
    assert not path_exists("proj/.cirrus.yml")
コード例 #6
0
def test_cli_without_tox(tmpfolder):
    # Given the command line without the tox option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then tox files should not exist
    assert not path_exists("proj/tox.ini")
コード例 #7
0
ファイル: test_tox.py プロジェクト: blue-yonder/pyscaffold
def test_cli_without_tox(tmpfolder):
    # Given the command line without the tox option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then tox files should not exist
    assert not path_exists("proj/tox.ini")
コード例 #8
0
def test_cli_without_pyproject(tmpfolder):
    # Given the command line without the pyproject option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then pyproject files should not exist
    assert not path_exists("proj/pyproject.toml")
コード例 #9
0
def test_cli_without_tox(tmpfolder):
    # Given the command line with --no-tox
    sys.argv = ["pyscaffold", "proj", "-vv", "--no-tox"]

    # when pyscaffold runs,
    run()

    # then tox files should not exist
    assert not Path("proj/tox.ini").exists()
コード例 #10
0
ファイル: test_namespace.py プロジェクト: vladdu/pyscaffold
def test_cli_without_namespace(tmpfolder):
    # Given the command line without the namespace option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then namespace dir should not exist
    assert not Path("proj/src/ns").exists()
コード例 #11
0
ファイル: test_namespace.py プロジェクト: ickma/pyscaffold
def test_cli_without_namespace(tmpfolder):
    # Given the command line without the namespace option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then namespace files should not exist
    assert not path_exists("proj/src/ns/__init__.py")
コード例 #12
0
def test_cli_without_pre_commit(tmpfolder):
    # Given the command line without the pre-commit option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then pre-commit files should not exist
    assert not path_exists("proj/.pre-commit-config.yaml")
コード例 #13
0
def test_cli_without_namespace(tmpfolder):
    # Given the command line without the namespace option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then namespace files should not exist
    assert not path_exists("proj/src/ns/__init__.py")
コード例 #14
0
def test_cli_with_no_skeleton_and_pretend(tmpfolder):
    # Given the command line with the no-skeleton and pretend options,
    sys.argv = ["pyscaffold", "--pretend", "--no-skeleton", "proj"]

    # when pyscaffold runs,
    run()

    # then skeleton file should not exist (or the project itself)
    assert not Path("proj/src/proj/skeleton.py").exists()
    assert not Path("proj").exists()
コード例 #15
0
def test_cli_with_no_skeleton(tmpfolder):
    # Given the command line with the no-skeleton option,
    sys.argv = ["pyscaffold", "--no-skeleton", "proj"]

    # when pyscaffold runs,
    run()

    # then skeleton file should not exist
    assert not Path("proj/src/proj/skeleton.py").exists()
    assert not Path("proj/tests/test_skeleton.py").exists()
コード例 #16
0
ファイル: test_namespace.py プロジェクト: vladdu/pyscaffold
def test_cli_with_namespace_and_pretend(tmpfolder):
    # Given the command line with the namespace and pretend options
    sys.argv = ["pyscaffold", "proj", "--namespace", "ns", "--pretend"]

    # when pyscaffold runs,
    run()

    # then namespace __init__ package should not exist (or even the project)
    assert not Path("proj/src/ns/__init__.py").exists()
    assert not Path("proj").exists()
コード例 #17
0
ファイル: test_django.py プロジェクト: cpaulik/pyscaffold
def test_cli_without_django(tmpfolder):
    # Given the command line without the django option,
    sys.argv = ["pyscaffold", PROJ_NAME]

    # when pyscaffold runs,
    run()

    # then django files should not exist
    for path in DJANGO_FILES:
        assert not path_exists(path)
コード例 #18
0
def test_cli_without_tox_but_pretend(tmpfolder):
    # Given the command line with --no-tox and --pretend
    sys.argv = ["pyscaffold", "proj", "-vv", "--no-tox", "--pretend"]

    # when pyscaffold runs,
    run()

    # then tox files should not exist (or even the project)
    assert not Path("proj/tox.ini").exists()
    assert not Path("proj").exists()
コード例 #19
0
def test_cli_without_travis(tmpfolder):
    # Given the command line without the travis option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then travis files should not exist
    assert not Path("proj/.travis.yml").exists()
    assert not Path("proj/tests/travis_install.sh").exists()
コード例 #20
0
def test_cli_without_cookiecutter(tmpfolder):
    # Given the command line without the cookiecutter option,
    sys.argv = ["pyscaffold", PROJ_NAME]

    # when pyscaffold runs,
    run()

    # then cookiecutter files should not exist
    for path in COOKIECUTTER_FILES:
        assert not path_exists(path)
コード例 #21
0
def test_cli_with_travis(tmpfolder):
    # Given the command line with the travis option,
    sys.argv = ["pyscaffold", "--travis", "proj"]

    # when pyscaffold runs,
    run()

    # then travis files should exist
    assert path_exists("proj/.travis.yml")
    assert path_exists("proj/tests/travis_install.sh")
コード例 #22
0
def test_cli_without_no_skeleton(tmpfolder):
    # Given the command line without the tox option,
    sys.argv = ["pyscaffold", "proj"]

    # when pyscaffold runs,
    run()

    # then skeleton file should exist
    assert path_exists("proj/src/proj/skeleton.py")
    assert path_exists("proj/tests/test_skeleton.py")
コード例 #23
0
def test_cli_with_pre_commit(tmpfolder):
    # Given the command line with the pre-commit option,
    sys.argv = ["pyscaffold", "--pre-commit", "proj"]

    # when pyscaffold runs,
    run()

    # then pre-commit files should exist
    assert Path("proj/.pre-commit-config.yaml").exists()
    assert Path("proj/.isort.cfg").exists()
コード例 #24
0
def test_cli_without_django(tmpfolder):
    # Given the command line without the django option,
    sys.argv = ["pyscaffold", PROJ_NAME]

    # when pyscaffold runs,
    run()

    # then django files should not exist
    for path in DJANGO_FILES:
        assert not path_exists(path)
コード例 #25
0
def test_cli_with_namespace(tmpfolder):
    # Given the command line with the namespace option,
    sys.argv = ["pyscaffold", "proj", "--namespace", "ns"]

    # when pyscaffold runs,
    run()

    # then namespace package should exist
    assert path_exists("proj/src/ns/__init__.py")
    assert path_exists("proj/src/ns/proj/__init__.py")
コード例 #26
0
def test_cli_with_pre_commit_or_pretend(tmpfolder):
    # Given the command line with the pre-commit option and pretend
    sys.argv = ["pyscaffold", "--pretend", "--pre-commit", "proj"]

    # when pyscaffold runs,
    run()

    # then pre-commit files should not exist (or the project itself)
    assert not Path("proj/.pre-commit-config.yaml").exists()
    assert not Path("proj").exists()
コード例 #27
0
ファイル: test_namespace.py プロジェクト: ickma/pyscaffold
def test_cli_with_namespace(tmpfolder):
    # Given the command line with the namespace option,
    sys.argv = ["pyscaffold", "proj", "--namespace", "ns"]

    # when pyscaffold runs,
    run()

    # then namespace package should exist
    assert path_exists("proj/src/ns/__init__.py")
    assert path_exists("proj/src/ns/proj/__init__.py")
コード例 #28
0
def test_cli_without_cookiecutter(tmpfolder):
    # Given the command line without the cookiecutter option,
    sys.argv = ["pyscaffold", PROJ_NAME]

    # when pyscaffold runs,
    run()

    # then cookiecutter files should not exist
    for path in COOKIECUTTER_FILES:
        assert not path_exists(path)
コード例 #29
0
def test_cli_with_empty_namespace(tmpfolder, capsys):
    # Given the command line with the namespace option,
    sys.argv = ["pyscaffold", "proj", "--namespace"]

    # when pyscaffold runs,
    with pytest.raises(SystemExit):
        run()

    # then an error occurs
    _, err = capsys.readouterr()
    assert 'expected one argument' in err
コード例 #30
0
ファイル: test_cirrus.py プロジェクト: vladdu/pyscaffold
def test_cli_with_cirrus_and_pretend(tmpfolder):
    # Given the command line with the cirrus and pretend options
    sys.argv = ["pyscaffold", "--pretend", "--cirrus", "proj"]

    # when pyscaffold runs,
    run()

    # then cirrus files should not exist
    assert not path_exists("proj/.cirrus.yml")
    # (or the project itself)
    assert not path_exists("proj")
コード例 #31
0
ファイル: test_namespace.py プロジェクト: ickma/pyscaffold
def test_cli_with_empty_namespace(tmpfolder, capsys):
    # Given the command line with the namespace option,
    sys.argv = ["pyscaffold", "proj", "--namespace"]

    # when pyscaffold runs,
    with pytest.raises(SystemExit):
        run()

    # then an error occurs
    _, err = capsys.readouterr()
    assert "expected one argument" in err
コード例 #32
0
def test_cli_with_travis_and_pretend(tmpfolder):
    # Given the command line with the travis option and pretend
    sys.argv = ["pyscaffold", "--pretend", "--travis", "proj"]

    # when pyscaffold runs,
    run()

    # then travis files (or the project itself) should not exist
    assert not Path("proj/.travis.yml").exists()
    assert not Path("proj/tests/travis_install.sh").exists()
    assert not Path("proj").exists()
コード例 #33
0
def test_with_numpydoc(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-numpydoc", "my_project"]
    cli.run()
    conffile = os.path.join(os.path.abspath(os.path.curdir), "my_project",
                            "docs", "conf.py")
    conf = imp.load_source('conf', conffile)
    assert sorted(conf.extensions) == sorted([
        'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
        'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage',
        'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.pngmath',
        'numpydoc'
    ])
コード例 #34
0
def test_cli_with_cookiecutter_but_no_template(tmpfolder, capsys):
    # Given the command line with the cookiecutter option, but no template
    sys.argv = ["pyscaffold", PROJ_NAME, "--cookiecutter"]

    # when pyscaffold runs,
    # then an exception should be raised.
    with pytest.raises(SystemExit):
        run()

    # make sure the exception is related to the missing argument
    out, err = capsys.readouterr()
    assert "--cookiecutter: expected one argument" in out + err
コード例 #35
0
ファイル: test_cirrus.py プロジェクト: vladdu/pyscaffold
def test_cli_with_cirrus(tmpfolder):
    # Given the command line with the cirrus option,
    sys.argv = ["pyscaffold", "--cirrus", "proj"]

    # when pyscaffold runs,
    run()

    # then files from cirrus and other extensions automatically added should
    # exist
    assert path_exists("proj/.cirrus.yml")
    assert path_exists("proj/tox.ini")
    assert path_exists("proj/.pre-commit-config.yaml")
コード例 #36
0
def test_cli_with_cookiecutter_but_no_template(tmpfolder, capsys):
    # Given the command line with the cookiecutter option, but no template
    sys.argv = ["pyscaffold", PROJ_NAME, "--cookiecutter"]

    # when pyscaffold runs,
    # then an exception should be raised.
    with pytest.raises(SystemExit):
        run()

    # make sure the exception is related to the missing argument
    out, err = capsys.readouterr()
    assert "--cookiecutter: expected one argument" in out + err
コード例 #37
0
ファイル: test_django.py プロジェクト: yssource/pyscaffold
def test_cli_with_django_and_update(tmpfolder, capsys):
    # Given a project exists
    create_project(project=PROJ_NAME)

    # when the project is updated
    # with the django extension,
    sys.argv = ["pyscaffold", PROJ_NAME, "--update", "--django"]
    run()

    # then a warning should be displayed
    out, err = capsys.readouterr()
    assert all(warn in out + err for warn in (
        'external tools', 'not supported', 'will be ignored'))
コード例 #38
0
ファイル: test_django.py プロジェクト: blue-yonder/pyscaffold
def test_cli_with_django_and_update(tmpfolder, capsys):
    # Given a project exists
    create_project(project=PROJ_NAME)

    # when the project is updated
    # with the django extension,
    sys.argv = ["pyscaffold", PROJ_NAME, "--update", "--django"]
    run()

    # then a warning should be displayed
    out, err = capsys.readouterr()
    assert all(warn in out + err for warn in (
        'external tools', 'not supported', 'will be ignored'))
コード例 #39
0
ファイル: test_cli.py プロジェクト: gh0std4ncer/pyscaffold
def test_with_numpydoc(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-numpydoc", "my_project"]
    cli.run()
    conffile = os.path.join(
        os.path.abspath(os.path.curdir), "my_project", "docs", "conf.py")
    conf = imp.load_source('conf', conffile)
    assert sorted(conf.extensions) == sorted(['sphinx.ext.autodoc',
                                              'sphinx.ext.intersphinx',
                                              'sphinx.ext.todo',
                                              'sphinx.ext.autosummary',
                                              'sphinx.ext.viewcode',
                                              'sphinx.ext.coverage',
                                              'sphinx.ext.doctest',
                                              'sphinx.ext.ifconfig',
                                              'sphinx.ext.pngmath',
                                              'numpydoc'])
コード例 #40
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_overwrite_git_repo(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "my_project"]
    cli.run()
    with pytest.raises(SystemExit):
        cli.run()
    sys.argv = ["pyscaffold", "--force", "my_project"]
    cli.run()
コード例 #41
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_with_namespaces(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-namespace", "com.blue_yonder", "my_project"]
    cli.run()
    assert os.path.exists("my_project/com/blue_yonder")
コード例 #42
0
ファイル: test_cli.py プロジェクト: willu47/pyscaffold
def test_with_gitlab(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-gitlab-ci", "my_project"]
    cli.run()
コード例 #43
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_django_proj(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-django", "my_project"]
    cli.run()
コード例 #44
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_overwrite_dir(tmpdir):  # noqa
    os.mkdir("my_project")
    sys.argv = ["pyscaffold", "--force", "my_project"]
    cli.run()
コード例 #45
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_run(tmpdir, git_mock):  # noqa
    sys.argv = ["pyscaffold", "my-project"]
    cli.run()
    assert os.path.exists(sys.argv[1])
コード例 #46
0
ファイル: test_cli.py プロジェクト: imoapps/pyscaffold
def test_with_travis(tmpdir):  # noqa
    sys.argv = ["pyscaffold", "--with-travis", "my_project"]
    cli.run()