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)
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)
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)
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)
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)
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
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"
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"
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()
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"
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
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"
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"
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
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())
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"
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"
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
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"
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)
def test_project_raises(): args = type("Namespace", (object, ), {"project": "non_existant"}) with pytest.raises(RuntimeError): info.project(args)
def test_project_raises(): opts = {"project": "non_existant"} with pytest.raises(RuntimeError): info.project(opts)
def test_project_old_setupcfg(tmpfolder): demoapp = Path(__file__).parent / "demoapp" with pytest.raises(exceptions.PyScaffoldTooOld): info.project({}, config_path=demoapp)
def test_project_raises(): args = type("Namespace", (object,), {"project": "non_existant"}) with pytest.raises(RuntimeError): info.project(args)