"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/utils/test_setup_reader.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

test_setup_reader.py  (poetry-1.1.15):test_setup_reader.py  (poetry-1.2.0)
from __future__ import annotations
import os import os
from typing import TYPE_CHECKING
import pytest import pytest
from poetry.core.semver.exceptions import ParseVersionError from poetry.core.version.exceptions import InvalidVersion
from poetry.utils._compat import PY35
from poetry.utils.setup_reader import SetupReader from poetry.utils.setup_reader import SetupReader
if TYPE_CHECKING:
from collections.abc import Callable
@pytest.fixture() @pytest.fixture()
def setup(): def setup() -> Callable[[str], str]:
def _setup(name): def _setup(name: str) -> str:
return os.path.join(os.path.dirname(__file__), "fixtures", "setups", nam e) return os.path.join(os.path.dirname(__file__), "fixtures", "setups", nam e)
return _setup return _setup
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_first_level_setup_call_with_direct_types(
) setup: Callable[[str], str]
def test_setup_reader_read_first_level_setup_call_with_direct_types(setup): ):
result = SetupReader.read_from_directory(setup("flask")) result = SetupReader.read_from_directory(setup("flask"))
expected_name = "Flask" expected_name = "Flask"
expected_version = None expected_version = None
expected_install_requires = [ expected_install_requires = [
"Werkzeug>=0.14", "Werkzeug>=0.14",
"Jinja2>=2.10", "Jinja2>=2.10",
"itsdangerous>=0.24", "itsdangerous>=0.24",
"click>=5.1", "click>=5.1",
] ]
skipping to change at line 42 skipping to change at line 50
"coverage", "coverage",
"tox", "tox",
"sphinx", "sphinx",
"pallets-sphinx-themes", "pallets-sphinx-themes",
"sphinxcontrib-log-cabinet", "sphinxcontrib-log-cabinet",
], ],
"docs": ["sphinx", "pallets-sphinx-themes", "sphinxcontrib-log-cabinet"] , "docs": ["sphinx", "pallets-sphinx-themes", "sphinxcontrib-log-cabinet"] ,
} }
expected_python_requires = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" expected_python_requires = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*"
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_first_level_setup_call_with_variables(
) setup: Callable[[str], str]
def test_setup_reader_read_first_level_setup_call_with_variables(setup): ):
result = SetupReader.read_from_directory(setup("requests")) result = SetupReader.read_from_directory(setup("requests"))
expected_name = None expected_name = None
expected_version = None expected_version = None
expected_install_requires = [ expected_install_requires = [
"chardet>=3.0.2,<3.1.0", "chardet>=3.0.2,<3.1.0",
"idna>=2.5,<2.8", "idna>=2.5,<2.8",
"urllib3>=1.21.1,<1.25", "urllib3>=1.21.1,<1.25",
"certifi>=2017.4.17", "certifi>=2017.4.17",
] ]
expected_extras_require = { expected_extras_require = {
"security": ["pyOpenSSL >= 0.14", "cryptography>=1.3.4", "idna>=2.0.0"], "security": ["pyOpenSSL >= 0.14", "cryptography>=1.3.4", "idna>=2.0.0"],
"socks": ["PySocks>=1.5.6, !=1.5.7"], "socks": ["PySocks>=1.5.6, !=1.5.7"],
'socks:sys_platform == "win32" and python_version == "2.7"': ["win_inet_ pton"], 'socks:sys_platform == "win32" and python_version == "2.7"': ["win_inet_ pton"],
} }
expected_python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" expected_python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_sub_level_setup_call_with_direct_types(
) setup: Callable[[str], str]
def test_setup_reader_read_sub_level_setup_call_with_direct_types(setup): ):
result = SetupReader.read_from_directory(setup("sqlalchemy")) result = SetupReader.read_from_directory(setup("sqlalchemy"))
expected_name = "SQLAlchemy" expected_name = "SQLAlchemy"
expected_version = None expected_version = None
expected_install_requires = [] expected_install_requires = []
expected_extras_require = { expected_extras_require = {
"mysql": ["mysqlclient"], "mysql": ["mysqlclient"],
"pymysql": ["pymysql"], "pymysql": ["pymysql"],
"postgresql": ["psycopg2"], "postgresql": ["psycopg2"],
"postgresql_pg8000": ["pg8000"], "postgresql_pg8000": ["pg8000"],
"postgresql_psycopg2cffi": ["psycopg2cffi"], "postgresql_psycopg2cffi": ["psycopg2cffi"],
"oracle": ["cx_oracle"], "oracle": ["cx_oracle"],
"mssql_pyodbc": ["pyodbc"], "mssql_pyodbc": ["pyodbc"],
"mssql_pymssql": ["pymssql"], "mssql_pymssql": ["pymssql"],
} }
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert result["python_requires"] is None assert result["python_requires"] is None
def test_setup_reader_read_setup_cfg(setup): def test_setup_reader_read_setup_cfg(setup: Callable[[str], str]):
result = SetupReader.read_from_directory(setup("with-setup-cfg")) result = SetupReader.read_from_directory(setup("with-setup-cfg"))
expected_name = "with-setup-cfg" expected_name = "with-setup-cfg"
expected_version = "1.2.3" expected_version = "1.2.3"
expected_install_requires = ["six", "tomlkit"] expected_install_requires = ["six", "tomlkit"]
expected_extras_require = { expected_extras_require = {
"validation": ["cerberus"], "validation": ["cerberus"],
"tests": ["pytest", "pytest-xdist", "pytest-cov"], "tests": ["pytest", "pytest-xdist", "pytest-cov"],
} }
expected_python_requires = ">=2.6,!=3.0,!=3.1,!=3.2,!=3.3" expected_python_requires = ">=2.6,!=3.0,!=3.1,!=3.2,!=3.3"
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
def test_setup_reader_read_setup_cfg_with_attr(setup): def test_setup_reader_read_setup_cfg_with_attr(setup: Callable[[str], str]):
with pytest.raises(ParseVersionError): with pytest.raises(InvalidVersion):
SetupReader.read_from_directory(setup("with-setup-cfg-attr")) SetupReader.read_from_directory(setup("with-setup-cfg-attr"))
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_setup_kwargs(setup: Callable[[str], str]):
)
def test_setup_reader_read_setup_kwargs(setup):
result = SetupReader.read_from_directory(setup("pendulum")) result = SetupReader.read_from_directory(setup("pendulum"))
expected_name = "pendulum" expected_name = "pendulum"
expected_version = "2.0.4" expected_version = "2.0.4"
expected_install_requires = ["python-dateutil>=2.6,<3.0", "pytzdata>=2018.3" ] expected_install_requires = ["python-dateutil>=2.6,<3.0", "pytzdata>=2018.3" ]
expected_extras_require = {':python_version < "3.5"': ["typing>=3.6,<4.0"]} expected_extras_require = {':python_version < "3.5"': ["typing>=3.6,<4.0"]}
expected_python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" expected_python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_setup_call_in_main(setup: Callable[[str], str]):
)
def test_setup_reader_read_setup_call_in_main(setup):
result = SetupReader.read_from_directory(setup("pyyaml")) result = SetupReader.read_from_directory(setup("pyyaml"))
expected_name = "PyYAML" expected_name = "PyYAML"
expected_version = "3.13" expected_version = "3.13"
expected_install_requires = [] expected_install_requires = []
expected_extras_require = {} expected_extras_require = {}
expected_python_requires = None expected_python_requires = None
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_read_extras_require_with_variables(setup: Callable[[str],
) str]):
def test_setup_reader_read_extras_require_with_variables(setup):
result = SetupReader.read_from_directory(setup("extras_require_with_vars")) result = SetupReader.read_from_directory(setup("extras_require_with_vars"))
expected_name = "extras_require_with_vars" expected_name = "extras_require_with_vars"
expected_version = "0.0.1" expected_version = "0.0.1"
expected_install_requires = [] expected_install_requires = []
expected_extras_require = {"test": ["pytest"]} expected_extras_require = {"test": ["pytest"]}
expected_python_requires = None expected_python_requires = None
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
assert expected_install_requires == result["install_requires"] assert result["install_requires"] == expected_install_requires
assert expected_extras_require == result["extras_require"] assert result["extras_require"] == expected_extras_require
assert expected_python_requires == result["python_requires"] assert result["python_requires"] == expected_python_requires
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4" def test_setup_reader_setuptools(setup: Callable[[str], str]):
)
def test_setup_reader_setuptools(setup):
result = SetupReader.read_from_directory(setup("setuptools_setup")) result = SetupReader.read_from_directory(setup("setuptools_setup"))
expected_name = "my_package" expected_name = "my_package"
expected_version = "0.1.2" expected_version = "0.1.2"
assert expected_name == result["name"] assert result["name"] == expected_name
assert expected_version == result["version"] assert result["version"] == expected_version
 End of changes. 20 change blocks. 
64 lines changed or deleted 64 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)