86
88
with pytest.raises(NotImplementedError):
91
def test_distribution__getHeaderAttrs_hit():
92
from pkginfo.distribution import HEADER_ATTRS_1_0
94
dist = _make_distribution()
95
assert dist._getHeaderAttrs() == HEADER_ATTRS_1_0
97
def test_distribution__getHeaderAttrs_miss_unknown():
98
from pkginfo.distribution import UnknownMetadataVersion
100
NONESUCH = "nonesuch"
102
dist = _make_distribution(NONESUCH)
103
with warnings.catch_warnings(record=True) as warned:
104
assert dist._getHeaderAttrs() == ()
106
assert len(warned) == 1
107
assert warned[0].category is UnknownMetadataVersion
108
assert NONESUCH in str(warned[0].message)
110
def test_distribution__getHeaderAttrs_miss_new():
111
from pkginfo.distribution import HEADER_ATTRS
112
from pkginfo.distribution import MAX_METADATA_VERSION_STR
113
from pkginfo.distribution import NewMetadataVersion
115
HIGH_VERSION = "99.99"
117
dist = _make_distribution(HIGH_VERSION)
118
with warnings.catch_warnings(record=True) as warned:
119
assert dist._getHeaderAttrs() == HEADER_ATTRS[MAX_METADATA_VERSION_STR]
121
assert len(warned) == 1
122
assert warned[0].category is NewMetadataVersion
123
assert HIGH_VERSION in str(warned[0].message)
89
125
def test_distribution_parse_given_unicode():
90
126
dist = _make_distribution()
91
127
dist.parse(u'Metadata-Version: 1.0\nName: lp722928_c3') # no raise
133
169
assert list(dist) == [x[1] for x in HEADER_ATTRS_2_3]
135
171
def test_distribution_parse_Metadata_Version_unknown():
172
from pkginfo.distribution import UnknownMetadataVersion
136
174
dist = _make_distribution(None)
137
dist.parse('Metadata-Version: 1.3')
176
with warnings.catch_warnings(record=True) as warned:
177
dist.parse('Metadata-Version: 1.3')
178
assert list(dist) == []
138
180
assert dist.metadata_version == '1.3'
139
assert list(dist) == []
182
assert len(warned) == 1
183
assert warned[0].category is UnknownMetadataVersion
184
assert "1.3" in str(warned[0].message)
141
186
def test_distribution_parse_Metadata_Version_override():
142
187
dist = _make_distribution('1.2')