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(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)
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_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"]
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/"
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"]
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_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)
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)
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_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())
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_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(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_parse_args(): args = ["my-project"] opts = runner.parse_args(args) assert opts.package == "my_project"
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)
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
def test_make_structure(): args = ["project", "-p", "package", "-d", "description"] args = runner.parse_args(args) struct = structure.make_structure(args) assert isinstance(struct, dict)
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)
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")
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)