summaryrefslogtreecommitdiff
path: root/tests/test_metadata.py
blob: 2e4f24c85556ffb0eb3c448685453934fd783f2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from wheel.metadata import pkginfo_to_metadata


def test_pkginfo_to_metadata(tmpdir):
    expected_metadata = [
        ('Metadata-Version', '2.1'),
        ('Name', 'spam'),
        ('Version', '0.1'),
        ('Requires-Dist', "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
        ('Requires-Dist', 'pywin32 ; sys_platform=="win32"'),
        ('Requires-Dist', 'foo @ http://host/foo.zip ; sys_platform=="win32"'),
        ('Provides-Extra', 'signatures'),
        ('Requires-Dist', 'pyxdg ; (sys_platform!="win32") and extra == \'signatures\''),
        ('Provides-Extra', 'empty_extra'),
        ('Provides-Extra', 'extra'),
        ('Requires-Dist', 'bar @ http://host/bar.zip ; extra == \'extra\''),
        ('Provides-Extra', 'faster-signatures'),
        ('Requires-Dist', "ed25519ll ; extra == 'faster-signatures'"),
        ('Provides-Extra', 'rest'),
        ('Requires-Dist', "docutils (>=0.8) ; extra == 'rest'"),
        ('Requires-Dist', "keyring ; extra == 'signatures'"),
        ('Requires-Dist', "keyrings.alt ; extra == 'signatures'"),
        ('Provides-Extra', 'test'),
        ('Requires-Dist', "pytest (>=3.0.0) ; extra == 'test'"),
        ('Requires-Dist', "pytest-cov ; extra == 'test'"),
    ]

    pkg_info = tmpdir.join('PKG-INFO')
    pkg_info.write("""\
Metadata-Version: 0.0
Name: spam
Version: 0.1
Provides-Extra: empty+extra
Provides-Extra: test
Provides-Extra: reST
Provides-Extra: signatures
Provides-Extra: Signatures
Provides-Extra: faster-signatures""")

    egg_info_dir = tmpdir.ensure_dir('test.egg-info')
    egg_info_dir.join('requires.txt').write("""\
pip@https://github.com/pypa/pip/archive/1.3.1.zip

[extra]
bar @ http://host/bar.zip

[empty+extra]

[:sys_platform=="win32"]
pywin32
foo @http://host/foo.zip

[faster-signatures]
ed25519ll

[reST]
docutils>=0.8

[signatures]
keyring
keyrings.alt

[Signatures:sys_platform!="win32"]
pyxdg

[test]
pytest>=3.0.0
pytest-cov""")

    message = pkginfo_to_metadata(egg_info_path=str(egg_info_dir), pkginfo_path=str(pkg_info))
    assert message.items() == expected_metadata