Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_supports_py2(requires_python, expected_result):
from flit.common import Metadata
metadata = object.__new__(Metadata)
metadata.requires_python = requires_python
result = metadata.supports_py2
assert result == expected_result
def test_extras_dev_warning(caplog):
info = read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
info['metadata']['requires_extra'] = {}
meta = Metadata(dict(name=info['module'], version='0.0', summary='', **info['metadata']))
assert '“dev-requires = ...” is obsolete' in caplog.text
assert set(meta.requires_dist) == {'apackage; extra == "dev"'}
def test_extra_conditions():
info = read_pkg_ini(samples_dir / 'extras.toml')
meta = Metadata(dict(name=info['module'], version='0.0', summary='', **info['metadata']))
assert set(meta.requires_dist) == {'toml', 'pytest; extra == "test"', 'requests; extra == "custom"'}
def test_extras_dev_conflict():
info = read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
with pytest.raises(ValueError, match=r'Ambiguity'):
Metadata(dict(name=info['module'], version='0.0', summary='', **info['metadata']))