def assert_git(extra_opts: PyprojectAttr, suffix: str) -> None:
     attr = PyprojectAttr({"git": "https://github.com/requests/requests.git"})
     attr.update(extra_opts)
     assert (
         handle_dict_attr("requests", attr, empty_pyproject_toml)
         == f"requests @ git+https://github.com/requests/requests.git{suffix}"
     )
def test_handle_url_arg(empty_pyproject_toml: PyProjectToml) -> None:
    attr = PyprojectAttr({"url": "https://my-site.com/mydep.whl"})
    assert (handle_dict_attr(
        "my_py_proj", attr,
        empty_pyproject_toml) == "my_py_proj @ https://my-site.com/mydep.whl")

    attr_with_extra = PyprojectAttr({"extras": ["extra1"]})
    attr_with_extra.update(attr)
    assert (handle_dict_attr("my_py_proj", attr_with_extra,
                             empty_pyproject_toml) ==
            "my_py_proj[extra1] @ https://my-site.com/mydep.whl")

    attr_with_mark = PyprojectAttr({"markers": "os_name=='darwin'"})
    attr_with_mark.update(attr)
    assert (handle_dict_attr("my_py_proj", attr_with_mark,
                             empty_pyproject_toml) ==
            "my_py_proj @ https://my-site.com/mydep.whl;(os_name=='darwin')")
示例#3
0
def test_add_markers() -> None:

    attr_mark = PyprojectAttr(
        {"markers": "platform_python_implementation == 'CPython'"})
    assert (add_markers("foo==1.0.0", attr_mark, "somepath") ==
            "foo==1.0.0;(platform_python_implementation == 'CPython')")

    attr_mark_adv = PyprojectAttr({
        "markers":
        "platform_python_implementation == 'CPython' or sys_platform == 'win32'"
    })
    assert (
        add_markers("foo==1.0.0", attr_mark_adv, "somepath") ==
        "foo==1.0.0;(platform_python_implementation == 'CPython' or sys_platform == 'win32')"
    )
    attr_basic_both = PyprojectAttr({"python": "3.6"})
    attr_basic_both.update(attr_mark)

    assert (
        add_markers("foo==1.0.0", attr_basic_both, "somepath") ==
        "foo==1.0.0;(platform_python_implementation == 'CPython') and (python_version == '3.6')"
    )
    attr_adv_py_both = PyprojectAttr({
        "python":
        "^3.6",
        "markers":
        "platform_python_implementation == 'CPython'"
    })
    assert add_markers("foo==1.0.0", attr_adv_py_both,
                       "somepath") == softwrap("""
        foo==1.0.0;(platform_python_implementation == 'CPython') and
        (python_version >= '3.6' and python_version< '4.0')
        """)

    attr_adv_both = PyprojectAttr({
        "python":
        "^3.6",
        "markers":
        "platform_python_implementation == 'CPython' or sys_platform == 'win32'",
    })
    assert add_markers("foo==1.0.0", attr_adv_both, "somepath") == softwrap("""
        foo==1.0.0;(platform_python_implementation == 'CPython' or
        sys_platform == 'win32') and (python_version >= '3.6' and python_version< '4.0')
        """)