示例#1
0
def test_project_with_no_versioneer(tmpdir):
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(IOError):
        info.project(args)
示例#2
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
示例#3
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
示例#4
0
def test_project_with_no_versioneer(tmpdir):
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(IOError):
        info.project(args)
示例#5
0
def test_project_with_wrong_setup(tmpdir):
    os.mkdir("my_project")
    open("my_project/versioneer.py", 'a').close()
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(AttributeError):
        info.project(args)
示例#6
0
def test_project_with_wrong_setup(tmpdir):
    os.mkdir("my_project")
    open("my_project/versioneer.py", 'a').close()
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(AttributeError):
        info.project(args)
示例#7
0
def test_make_structure_with_pre_commit_hooks():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-pre-commit"]
    args = runner.parse_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
    assert ".pre-commit-config.yaml" in struct["project"]
示例#8
0
def test_safe_set():
    args = ["my-project", "-u", "http://www.blue-yonder.com/"]
    args = runner.parse_args(args)
    utils.safe_set(args, "new_option", "value")
    assert args.new_option == "value"
    utils.safe_set(args, "license", "my license")
    assert args.license == "my license"
    utils.safe_set(args, "url", "http://www.python.org/")
    assert args.url == "http://www.blue-yonder.com/"
示例#9
0
def test_safe_set():
    args = ["my-project", "-u", "http://www.blue-yonder.com/"]
    args = runner.parse_args(args)
    utils.safe_set(args, "new_option", "value")
    assert args.new_option == "value"
    utils.safe_set(args, "license", "my license")
    assert args.license == "my license"
    utils.safe_set(args, "url", "http://www.python.org/")
    assert args.url == "http://www.blue-yonder.com/"
示例#10
0
def test_make_structure_with_pre_commit_hooks():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-pre-commit"]
    args = runner.parse_args(args)
    args = structure.set_default_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
    assert ".pre-commit-config.yaml" in struct["project"]
示例#11
0
def test_project_with_junit_coverage_args_overwritten(tmpdir):
    old_args = ["my_project"]
    runner.main(old_args)
    args = ["my_project", "--with-junit-xml", "--with-coverage-xml",
            "--with-coverage-html"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.junit_xml is True
    assert new_args.coverage_xml is True
    assert new_args.coverage_html is True
示例#12
0
def test_make_structure_with_tox():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-tox"]
    args = runner.parse_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
    assert "tox.ini" in struct["project"]
    assert isinstance(struct["project"]["tox.ini"], six.string_types)
示例#13
0
def test_make_structure_with_tox():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-tox"]
    args = runner.parse_args(args)
    args = structure.set_default_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
    assert "tox.ini" in struct["project"]
    assert isinstance(struct["project"]["tox.ini"], six.string_types)
示例#14
0
def test_project_without_args(tmpdir):  # noqa
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    runner.main(old_args)
    args = ["my_project"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.blue-yonder.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "none"
    assert new_args.description == "my description"
示例#15
0
def test_project_with_junit_coverage_args_overwritten(tmpdir):
    old_args = ["my_project"]
    runner.main(old_args)
    args = [
        "my_project", "--with-junit-xml", "--with-coverage-xml",
        "--with-coverage-html"
    ]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.junit_xml is True
    assert new_args.coverage_xml is True
    assert new_args.coverage_html is True
示例#16
0
def test_project_with_args(tmpdir):
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    runner.main(old_args)
    args = ["my_project", "-u", "http://www.google.com/",
            "-d", "other description", "-l", "new-bsd"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.google.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "new BSD"
    assert new_args.description == "other description"
示例#17
0
def test_project_without_args(tmpdir):  # noqa
    old_args = [
        "my_project", "-u", "http://www.blue-yonder.com/", "-d",
        "my description"
    ]
    runner.main(old_args)
    args = ["my_project"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.blue-yonder.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "none"
    assert new_args.description == "my description"
示例#18
0
def test_add_namespace():
    args = ["project",
            "-p", "package",
            "--with-namespace", "com.blue_yonder"]
    args = runner.parse_args(args)
    args.namespace = runner.prepare_namespace(args.namespace)
    struct = {"project": {"package": {"file1": "Content"}}}
    ns_struct = structure.add_namespace(args, struct)
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_struct["project"].keys())
    assert {"blue_yonder", "__init__.py"} == set(
        ns_struct["project"]["com"].keys())
    assert "package" in list(ns_struct["project"]["com"]["blue_yonder"].keys())
示例#19
0
def test_project_without_args(tmpdir):
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    runner.main(old_args)
    args = ["my_project"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.blue-yonder.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "new BSD"
    assert new_args.description == "my description"
    assert new_args.junit_xml is False
    assert new_args.coverage_xml is False
    assert new_args.coverage_html is False
示例#20
0
def test_project_without_args(tmpdir):
    old_args = [
        "my_project", "-u", "http://www.blue-yonder.com/", "-d",
        "my description"
    ]
    runner.main(old_args)
    args = ["my_project"]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.blue-yonder.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "new BSD"
    assert new_args.description == "my description"
    assert new_args.junit_xml is False
    assert new_args.coverage_xml is False
    assert new_args.coverage_html is False
示例#21
0
def test_project_with_args(tmpdir):
    old_args = [
        "my_project", "-u", "http://www.blue-yonder.com/", "-d",
        "my description"
    ]
    runner.main(old_args)
    args = [
        "my_project", "-u", "http://www.google.com/", "-d",
        "other description", "-l", "new-bsd"
    ]
    args = runner.parse_args(args)
    new_args = info.project(args)
    assert new_args.url == "http://www.google.com/"
    assert new_args.package == "my_project"
    assert new_args.license == "new BSD"
    assert new_args.description == "other description"
示例#22
0
def test_parse_args():
    args = ["my-project"]
    opts = runner.parse_args(args)
    assert opts.package == "my_project"
示例#23
0
def test_project_with_no_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
示例#24
0
def test_safe_get():
    args = ["my-project", "-u", "http://www.blue-yonder.com/"]
    args = runner.parse_args(args)
    assert utils.safe_get(args, "url") == "http://www.blue-yonder.com/"
    assert utils.safe_get(args, "non_existent") is None
示例#25
0
def test_make_structure():
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
示例#26
0
def test_safe_get():
    args = ["my-project", "-u", "http://www.blue-yonder.com/"]
    args = runner.parse_args(args)
    assert utils.safe_get(args, "url") == "http://www.blue-yonder.com/"
    assert utils.safe_get(args, "non_existent") is None
示例#27
0
def test_create_django_project(nodjango_admin_mock):
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        structure.create_django_proj(args)
示例#28
0
def test_set_default_args():
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    new_args = structure.set_default_args(args)
    assert not hasattr(args, "author")
    assert hasattr(new_args, "author")
示例#29
0
def test_project_with_no_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    args = ["my_project"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
示例#30
0
def test_parse_args():
    args = ["my-project"]
    opts = runner.parse_args(args)
    assert opts.package == "my_project"
示例#31
0
def test_make_structure():
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    struct = structure.make_structure(args)
    assert isinstance(struct, dict)
示例#32
0
def test_set_default_args():
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    new_args = structure.set_default_args(args)
    assert not hasattr(args, "author")
    assert hasattr(new_args, "author")
示例#33
0
def test_create_django_project(nodjango_admin_mock):  # noqa
    args = ["project", "-p", "package", "-d", "description"]
    args = runner.parse_args(args)
    with pytest.raises(RuntimeError):
        structure.create_django_proj(args)