Example #1
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Example #2
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)
Example #3
0
def test_project_with_wrong_setup(tmpfolder):
    os.mkdir("my_project")
    open("my_project/setup.py", "a").close()
    args = ["my_project"]
    opts = cli.parse_args(args)
    with pytest.raises(FileNotFoundError):
        info.project(opts)
Example #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)
Example #5
0
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)
Example #6
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Example #7
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)
Example #8
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)
Example #9
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
Example #10
0
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)
    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"
Example #11
0
def test_project_with_args(tmpdir):  # noqa
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    cli.main(old_args)
    args = ["my_project", "-u", "http://www.google.com/",
            "-d", "other description"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts['url'] == "http://www.blue-yonder.com/"
    assert new_opts['package'] == "my_project"
    assert new_opts['description'] == "my description"
Example #12
0
def test_save_action(default_file):
    # When the file does not exist
    assert not default_file.exists()
    opts = dict(author="author", email="email", license="MPL-2.0")
    config.save({}, {**opts, "save_config": default_file})
    # it will create a valid file from the point of view of parsing
    assert default_file.exists()
    parsed = info.project({}, default_file)
    assert all(parsed[k] == v for k, v in opts.items())
    # and the file will contain instructions / references
    assert "pyscaffold.org" in default_file.read_text()
Example #13
0
def test_project_with_args(tmpdir):  # noqa
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    cli.main(old_args)
    args = ["my_project", "-u", "http://www.google.com/",
            "-d", "other description"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts['url'] == "http://www.blue-yonder.com/"
    assert new_opts['package'] == "my_project"
    assert new_opts['description'] == "my description"
Example #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"
Example #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
Example #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"
Example #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"
Example #18
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
Example #19
0
def test_save_action_existing_file(default_file, monkeypatch):
    # Given default values that differ a bit from the given opts
    monkeypatch.setattr(info, "username", lambda *_: "John Doe")
    monkeypatch.setattr(info, "email", lambda *_: "email")
    monkeypatch.setitem(api.DEFAULT_OPTIONS, "license", "MPL-2.0")
    opts = dict(author="author", email="email", license="MPL-2.0")
    # When the file exists and new config is saved
    existing_config(default_file)
    config.save({}, {**opts, "save_config": default_file})
    # Then metadata that differs from default will change
    expected = dict(author="author",
                    email="*****@*****.**",
                    license="GPL-3.0-only")
    parsed = info.project({}, default_file)
    assert all(parsed[k] == v for k, v in expected.items())
Example #20
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"
Example #21
0
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)
    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"
Example #22
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
Example #23
0
def test_project_with_args(tmpfolder):
    old_args = [
        "my_project",
        "-u",
        "http://www.blue-yonder.com/",
        "-d",
        "my description",
    ]
    cli.main(old_args)
    args = [
        "my_project", "-u", "http://www.google.com/", "-d", "other description"
    ]
    opts = cli.parse_args(args)
    opts = cli.process_opts(opts)
    new_opts = info.project(opts)
    assert new_opts["url"] == "http://www.google.com/"
    assert new_opts["package"] == "my_project"
    assert new_opts["description"] == "other description"
Example #24
0
def test_project_with_no_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Example #25
0
def test_project_raises():
    args = type("Namespace", (object, ), {"project": "non_existant"})
    with pytest.raises(RuntimeError):
        info.project(args)
Example #26
0
def test_project_raises():
    opts = {"project": "non_existant"}
    with pytest.raises(RuntimeError):
        info.project(opts)
Example #27
0
def test_project_old_setupcfg(tmpfolder):
    demoapp = Path(__file__).parent / "demoapp"
    with pytest.raises(exceptions.PyScaffoldTooOld):
        info.project({}, config_path=demoapp)
Example #28
0
def test_project_raises():
    opts = {"project": "non_existant"}
    with pytest.raises(RuntimeError):
        info.project(opts)
Example #29
0
def test_project_with_no_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Example #30
0
def test_project_raises():
    args = type("Namespace", (object,), {"project": "non_existant"})
    with pytest.raises(RuntimeError):
        info.project(args)