FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
importlib_metadata/tests/test_main.py at main · python/importlib_metadata · GitHub
python
importlib_metadata
Repository navigation
Code
Issues
9
(9)
Pull requests
4
(4)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
importlib_metadata
/
tests
/
test_main.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
582 lines (487 loc) · 19.6 KB
Breadcrumbs
importlib_metadata
/
tests
/
test_main.py
Copy path
File metadata and controls
582 lines (487 loc) · 19.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
import
contextlib
import
importlib
import
io
import
pickle
import
re
import
unittest
import
pyfakefs
.
fake_filesystem_unittest
as
ffs
from
test
.
support
import
os_helper
import
importlib_metadata
from
importlib_metadata
import
(
Distribution
,
EntryPoint
,
MetadataNotFound
,
PackageNotFoundError
,
_unique
,
diagnose
,
distributions
,
entry_points
,
metadata
,
packages_distributions
,
version
,
)
from
.
import
fixtures
from
.
_path
import
Symlink
from
.
compat
.
py314
import
frozendict
class
BasicTests
(
fixtures
.
DistInfoPkg
,
unittest
.
TestCase
):
version_pattern
=
r'\d+\.\d+(\.\d)?'
def
test_retrieves_version_of_self
(
self
):
dist
=
Distribution
.
from_name
(
'distinfo-pkg'
)
assert
isinstance
(
dist
.
version
,
str
)
assert
re
.
match
(
self
.
version_pattern
,
dist
.
version
)
def
test_for_name_does_not_exist
(
self
):
with
self
.
assertRaises
(
PackageNotFoundError
):
Distribution
.
from_name
(
'does-not-exist'
)
def
test_package_not_found_mentions_metadata
(
self
):
"""
When a package is not found, that could indicate that the
package is not installed or that it is installed without
metadata. Ensure the exception mentions metadata to help
guide users toward the cause. See #124.
"""
with
self
.
assertRaises
(
PackageNotFoundError
)
as
ctx
:
Distribution
.
from_name
(
'does-not-exist'
)
assert
"metadata"
in
str
(
ctx
.
exception
)
def
test_abc_enforced
(
self
):
with
self
.
assertRaises
(
TypeError
):
type
(
'DistributionSubclass'
, (
Distribution
,), {})()
@
fixtures
.
parameterize
(
dict
(
text
=
'Name: foo
\n
Version: 1.0
\n
'
,
expected
=
True
),
dict
(
text
=
None
,
expected
=
False
),
)
def
test_detects_metadata_by_reading
(
self
,
text
,
expected
):
"""
A distribution that isn't path-based takes the default
detection, which reads what it cannot otherwise detect.
"""
class
Provided
(
Distribution
):
def
read_text
(
self
,
filename
):
return
text
if
filename
==
'METADATA'
else
None
def
locate_file
(
self
,
path
):
return
None
# pragma: no cover
assert
Provided
().
_has_metadata
()
is
expected
@
fixtures
.
parameterize
(
dict
(
name
=
None
),
dict
(
name
=
''
),
)
def
test_invalid_inputs_to_from_name
(
self
,
name
):
with
self
.
assertRaises
(
ValueError
):
Distribution
.
from_name
(
name
)
class
ImportTests
(
fixtures
.
DistInfoPkg
,
unittest
.
TestCase
):
def
test_import_nonexistent_module
(
self
):
# Ensure that the MetadataPathFinder does not crash an import of a
# non-existent module.
with
self
.
assertRaises
(
ImportError
):
importlib
.
import_module
(
'does_not_exist'
)
def
test_resolve
(
self
):
ep
=
entry_points
(
group
=
'entries'
)[
'main'
]
self
.
assertEqual
(
ep
.
load
().
__name__
,
"main"
)
def
test_entrypoint_with_colon_in_name
(
self
):
ep
=
entry_points
(
group
=
'entries'
)[
'ns:sub'
]
self
.
assertEqual
(
ep
.
value
,
'mod:main'
)
def
test_resolve_without_attr
(
self
):
ep
=
EntryPoint
(
name
=
'ep'
,
value
=
'importlib_metadata'
,
group
=
'grp'
,
)
assert
ep
.
load
()
is
importlib_metadata
class
NameNormalizationTests
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
unittest
.
TestCase
):
@
staticmethod
def
make_pkg
(
name
):
"""
Create minimal metadata for a dist-info package with
the indicated name on the file system.
"""
return
{
f'
{
name
}
.dist-info'
: {
'METADATA'
:
'VERSION: 1.0
\n
'
,
},
}
def
test_dashes_in_dist_name_found_as_underscores
(
self
):
"""
For a package with a dash in the name, the dist-info metadata
uses underscores in the name. Ensure the metadata loads.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'my_pkg'
),
self
.
site_dir
)
assert
version
(
'my-pkg'
)
==
'1.0'
def
test_dist_name_found_as_any_case
(
self
):
"""
Ensure the metadata loads when queried with any case.
"""
pkg_name
=
'CherryPy'
fixtures
.
build_files
(
self
.
make_pkg
(
pkg_name
),
self
.
site_dir
)
assert
version
(
pkg_name
)
==
'1.0'
assert
version
(
pkg_name
.
lower
())
==
'1.0'
assert
version
(
pkg_name
.
upper
())
==
'1.0'
def
test_unique_distributions
(
self
):
"""
Two distributions varying only by non-normalized name on
the file system should resolve as the same.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'abc'
),
self
.
site_dir
)
before
=
list
(
_unique
(
distributions
()))
alt_site_dir
=
self
.
fixtures
.
enter_context
(
fixtures
.
tmp_path
())
self
.
fixtures
.
enter_context
(
self
.
add_sys_path
(
alt_site_dir
))
fixtures
.
build_files
(
self
.
make_pkg
(
'ABC'
),
alt_site_dir
)
after
=
list
(
_unique
(
distributions
()))
assert
len
(
after
)
==
len
(
before
)
class
InvalidMetadataTests
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
unittest
.
TestCase
):
@
staticmethod
def
make_pkg
(
name
,
files
=
frozendict
(
METADATA
=
"VERSION: 1.0"
)):
"""
Create metadata for a dist-info package with name and files.
"""
return
{
f'
{
name
}
.dist-info'
:
files
,
}
def
test_valid_dists_preferred
(
self
):
"""
Dists with metadata should be preferred when discovered by name.
Ref python/importlib_metadata#489.
"""
# create three dists with the valid one in the middle (lexicographically)
# such that on most file systems, the valid one is never naturally first.
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.0'
,
files
=
{}),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.1'
),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.2'
,
files
=
{}),
self
.
site_dir
)
dist
=
Distribution
.
from_name
(
'foo'
)
assert
dist
.
version
==
"1.0"
def
test_invalid_dists_deferred
(
self
):
"""
Preferring the valid dists defers the invalid ones to the end
rather than dropping them.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.0'
,
files
=
{}),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.1'
),
self
.
site_dir
)
dists
=
list
(
Distribution
.
_prefer_valid
(
Distribution
.
discover
(
name
=
'foo'
)))
assert
len
(
dists
)
==
2
assert
dists
[
0
].
version
==
"1.0"
def
test_entry_points_from_valid_dist
(
self
):
"""
Entry points come from the valid dist even when an invalid one
of the same name is discovered first.
Ref python/importlib_metadata#534.
"""
# as in test_valid_dists_preferred, bracket the valid dist so that
# on most file systems it is never naturally first.
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.0'
,
files
=
{}),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.1'
,
files
=
{
'METADATA'
:
"VERSION: 1.0"
,
'entry_points.txt'
:
'[shadowed]
\n
ep = foo:main
\n
'
,
},
),
self
.
site_dir
,
)
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.2'
,
files
=
{}),
self
.
site_dir
)
assert
entry_points
(
group
=
'shadowed'
).
names
==
{
'ep'
}
def
test_missing_metadata
(
self
):
"""
Dists with a missing metadata file should raise ``MetadataNotFound``.
Ref python/importlib_metadata#493 and python/cpython#143387.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'foo-4.3'
,
files
=
{}),
self
.
site_dir
)
with
self
.
assertRaises
(
MetadataNotFound
):
_
=
Distribution
.
from_name
(
'foo'
).
metadata
with
self
.
assertRaises
(
MetadataNotFound
):
metadata
(
'foo'
)
def
test_diagnose_reports_invalid
(
self
):
"""
The diagnostic should report invalid dists by location
rather than crashing on them.
Ref python/importlib_metadata#548.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'nameless-1.0'
),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'empty-1.0'
,
files
=
{}),
self
.
site_dir
)
out
=
io
.
StringIO
()
with
contextlib
.
redirect_stdout
(
out
):
diagnose
.
inspect
(
str
(
self
.
site_dir
))
report
=
out
.
getvalue
()
assert
'empty-1.0.dist-info (no metadata)'
in
report
assert
'nameless-1.0.dist-info (metadata without a name)'
in
report
def
test_missing_required_metadata
(
self
):
"""
A missing required metadata field should raise a ``KeyError``
naming the field and locating the distribution.
Ref python/importlib_metadata#508.
"""
fixtures
.
build_files
(
self
.
make_pkg
(
'nameless-4.4'
),
self
.
site_dir
)
fixtures
.
build_files
(
self
.
make_pkg
(
'unversioned-4.4'
,
files
=
dict
(
METADATA
=
'Name: unversioned'
)),
self
.
site_dir
,
)
nameless
=
Distribution
.
at
(
self
.
site_dir
/
'nameless-4.4.dist-info'
)
with
self
.
assertRaisesRegex
(
KeyError
,
'Name.*nameless-4.4.dist-info'
):
nameless
.
name
unversioned
=
Distribution
.
at
(
self
.
site_dir
/
'unversioned-4.4.dist-info'
)
with
self
.
assertRaisesRegex
(
KeyError
,
'Version.*unversioned-4.4.dist-info'
):
unversioned
.
version
class
NonASCIITests
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
unittest
.
TestCase
):
@
staticmethod
def
pkg_with_non_ascii_description
(
site_dir
):
"""
Create minimal metadata for a package with non-ASCII in
the description.
"""
contents
=
{
'portend.dist-info'
: {
'METADATA'
:
'Description: pôrˈtend'
,
},
}
fixtures
.
build_files
(
contents
,
site_dir
)
return
'portend'
@
staticmethod
def
pkg_with_non_ascii_description_egg_info
(
site_dir
):
"""
Create minimal metadata for an egg-info package with
non-ASCII in the description.
"""
contents
=
{
'portend.dist-info'
: {
'METADATA'
:
"""
Name: portend
pôrˈtend"""
,
},
}
fixtures
.
build_files
(
contents
,
site_dir
)
return
'portend'
def
test_metadata_loads
(
self
):
pkg_name
=
self
.
pkg_with_non_ascii_description
(
self
.
site_dir
)
meta
=
metadata
(
pkg_name
)
assert
meta
[
'Description'
]
==
'pôrˈtend'
def
test_metadata_loads_egg_info
(
self
):
pkg_name
=
self
.
pkg_with_non_ascii_description_egg_info
(
self
.
site_dir
)
meta
=
metadata
(
pkg_name
)
assert
meta
[
'Description'
]
==
'pôrˈtend'
class
DiscoveryTests
(
fixtures
.
EggInfoPkg
,
fixtures
.
EggInfoPkgPipInstalledNoToplevel
,
fixtures
.
EggInfoPkgPipInstalledNoModules
,
fixtures
.
EggInfoPkgSourcesFallback
,
fixtures
.
DistInfoPkg
,
unittest
.
TestCase
,
):
def
test_package_discovery
(
self
):
dists
=
list
(
distributions
())
assert
all
(
isinstance
(
dist
,
Distribution
)
for
dist
in
dists
)
assert
any
(
dist
.
metadata
[
'Name'
]
==
'egginfo-pkg'
for
dist
in
dists
)
assert
any
(
dist
.
metadata
[
'Name'
]
==
'egg_with_module-pkg'
for
dist
in
dists
)
assert
any
(
dist
.
metadata
[
'Name'
]
==
'egg_with_no_modules-pkg'
for
dist
in
dists
)
assert
any
(
dist
.
metadata
[
'Name'
]
==
'sources_fallback-pkg'
for
dist
in
dists
)
assert
any
(
dist
.
metadata
[
'Name'
]
==
'distinfo-pkg'
for
dist
in
dists
)
def
test_invalid_usage
(
self
):
with
self
.
assertRaises
(
ValueError
):
list
(
distributions
(
context
=
'something'
,
name
=
'else'
))
def
test_interleaved_discovery
(
self
):
"""
Ensure interleaved searches are safe.
When the search is cached, it is possible for searches to be
interleaved, so make sure those use-cases are safe.
Ref #293
"""
dists
=
distributions
()
next
(
dists
)
version
(
'egginfo-pkg'
)
next
(
dists
)
class
DirectoryTest
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
unittest
.
TestCase
):
def
test_egg_info
(
self
):
# make an `EGG-INFO` directory that's unrelated
self
.
site_dir
.
joinpath
(
'EGG-INFO'
).
mkdir
()
# used to crash with `IsADirectoryError`
with
self
.
assertRaises
(
PackageNotFoundError
):
version
(
'unknown-package'
)
def
test_egg
(
self
):
egg
=
self
.
site_dir
.
joinpath
(
'foo-3.6.egg'
)
egg
.
mkdir
()
with
self
.
add_sys_path
(
egg
),
self
.
assertRaises
(
PackageNotFoundError
):
version
(
'foo'
)
class
MissingSysPath
(
fixtures
.
OnSysPath
,
unittest
.
TestCase
):
site_dir
=
'/does-not-exist'
def
test_discovery
(
self
):
"""
Discovering distributions should succeed even if
there is an invalid path on sys.path.
"""
importlib_metadata
.
distributions
()
class
InaccessibleSysPath
(
fixtures
.
OnSysPath
,
ffs
.
TestCase
):
site_dir
=
'/access-denied'
def
setUp
(
self
):
super
().
setUp
()
self
.
setUpPyfakefs
()
self
.
fs
.
create_dir
(
self
.
site_dir
,
perm_bits
=
000
)
def
test_discovery
(
self
):
"""
Discovering distributions should succeed even if
there is an invalid path on sys.path.
"""
list
(
importlib_metadata
.
distributions
())
class
TestEntryPoints
(
unittest
.
TestCase
):
def
__init__
(
self
,
*
args
):
super
().
__init__
(
*
args
)
self
.
ep
=
importlib_metadata
.
EntryPoint
(
name
=
'name'
,
value
=
'value'
,
group
=
'group'
)
def
test_entry_point_pickleable
(
self
):
revived
=
pickle
.
loads
(
pickle
.
dumps
(
self
.
ep
))
assert
revived
==
self
.
ep
def
test_positional_args
(
self
):
"""
Capture legacy (namedtuple) construction, discouraged.
"""
EntryPoint
(
'name'
,
'value'
,
'group'
)
def
test_immutable
(
self
):
"""EntryPoints should be immutable"""
with
self
.
assertRaises
(
AttributeError
):
self
.
ep
.
name
=
'badactor'
def
test_repr
(
self
):
assert
'EntryPoint'
in
repr
(
self
.
ep
)
assert
'name='
in
repr
(
self
.
ep
)
assert
"'name'"
in
repr
(
self
.
ep
)
def
test_hashable
(
self
):
"""EntryPoints should be hashable"""
hash
(
self
.
ep
)
def
test_module
(
self
):
assert
self
.
ep
.
module
==
'value'
def
test_attr
(
self
):
assert
self
.
ep
.
attr
is
None
def
test_sortable
(
self
):
"""
EntryPoint objects are sortable, but result is undefined.
"""
sorted
([
EntryPoint
(
name
=
'b'
,
value
=
'val'
,
group
=
'group'
),
EntryPoint
(
name
=
'a'
,
value
=
'val'
,
group
=
'group'
),
])
class
FileSystem
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
fixtures
.
FileBuilder
,
unittest
.
TestCase
):
def
test_unicode_dir_on_sys_path
(
self
):
"""
Ensure a Unicode subdirectory of a directory on sys.path
does not crash.
"""
fixtures
.
build_files
(
{
self
.
unicode_filename
(): {}},
prefix
=
self
.
site_dir
,
)
list
(
distributions
())
class
PackagesDistributionsPrebuiltTest
(
fixtures
.
ZipFixtures
,
unittest
.
TestCase
):
def
test_packages_distributions_example
(
self
):
self
.
_fixture_on_path
(
'example-21.12-py3-none-any.whl'
)
assert
packages_distributions
()[
'example'
]
==
[
'example'
]
def
test_packages_distributions_example2
(
self
):
"""
Test packages_distributions on a wheel built
by trampolim.
"""
self
.
_fixture_on_path
(
'example2-1.0.0-py3-none-any.whl'
)
assert
packages_distributions
()[
'example2'
]
==
[
'example2'
]
class
PackagesDistributionsTest
(
fixtures
.
OnSysPath
,
fixtures
.
SiteDir
,
unittest
.
TestCase
):
def
test_packages_distributions_neither_toplevel_nor_files
(
self
):
"""
Test a package built without 'top-level.txt' or a file list.
"""
fixtures
.
build_files
(
{
'trim_example-1.0.0.dist-info'
: {
'METADATA'
:
"""
Name: trim_example
Version: 1.0.0
"""
,
}
},
prefix
=
self
.
site_dir
,
)
packages_distributions
()
def
test_packages_distributions_all_module_types
(
self
):
"""
Test top-level modules detected on a package without 'top-level.txt'.
"""
suffixes
=
importlib
.
machinery
.
all_suffixes
()
metadata
=
dict
(
METADATA
=
"""
Name: all_distributions
Version: 1.0.0
"""
,
)
files
=
{
'all_distributions-1.0.0.dist-info'
:
metadata
,
}
for
i
,
suffix
in
enumerate
(
suffixes
):
files
.
update
({
f'importable-name
{
i
}
{
suffix
}
'
:
''
,
f'in_namespace_
{
i
}
'
: {
f'mod
{
suffix
}
'
:
''
,
},
f'in_package_
{
i
}
'
: {
'__init__.py'
:
''
,
f'mod
{
suffix
}
'
:
''
,
},
})
metadata
.
update
(
RECORD
=
fixtures
.
build_record
(
files
))
fixtures
.
build_files
(
files
,
prefix
=
self
.
site_dir
)
distributions
=
packages_distributions
()
for
i
in
range
(
len
(
suffixes
)):
assert
distributions
[
f'importable-name
{
i
}
'
]
==
[
'all_distributions'
]
assert
distributions
[
f'in_namespace_
{
i
}
'
]
==
[
'all_distributions'
]
assert
distributions
[
f'in_package_
{
i
}
'
]
==
[
'all_distributions'
]
assert
not
any
(
name
.
endswith
(
'.dist-info'
)
for
name
in
distributions
)
@
os_helper
.
skip_unless_symlink
def
test_packages_distributions_symlinked_top_level
(
self
)
->
None
:
"""
Distribution is resolvable from a simple top-level symlink in RECORD.
See #452.
"""
files
:
fixtures
.
FilesSpec
=
{
"symlinked_pkg-1.0.0.dist-info"
: {
"METADATA"
:
"""
Name: symlinked-pkg
Version: 1.0.0
"""
,
"RECORD"
:
"symlinked,,
\n
"
,
},
".symlink.target"
: {},
"symlinked"
:
Symlink
(
".symlink.target"
),
}
fixtures
.
build_files
(
files
,
self
.
site_dir
)
assert
packages_distributions
()[
'symlinked'
]
==
[
'symlinked-pkg'
]
class
PackagesDistributionsEggTest
(
fixtures
.
EggInfoPkg
,
fixtures
.
EggInfoPkgPipInstalledNoToplevel
,
fixtures
.
EggInfoPkgPipInstalledNoModules
,
fixtures
.
EggInfoPkgSourcesFallback
,
unittest
.
TestCase
,
):
def
test_packages_distributions_on_eggs
(
self
):
"""
Test old-style egg packages with a variation of 'top_level.txt',
'SOURCES.txt', and 'installed-files.txt', available.
"""
distributions
=
packages_distributions
()
def
import_names_from_package
(
package_name
):
return
{
import_name
for
import_name
,
package_names
in
distributions
.
items
()
if
package_name
in
package_names
}
# egginfo-pkg declares one import ('mod') via top_level.txt
assert
import_names_from_package
(
'egginfo-pkg'
)
==
{
'mod'
}
# egg_with_module-pkg has one import ('egg_with_module') inferred from
# installed-files.txt (top_level.txt is missing)
assert
import_names_from_package
(
'egg_with_module-pkg'
)
==
{
'egg_with_module'
}
# egg_with_no_modules-pkg should not be associated with any import names
# (top_level.txt is empty, and installed-files.txt has no .py files)
assert
import_names_from_package
(
'egg_with_no_modules-pkg'
)
==
set
()
# sources_fallback-pkg has one import ('sources_fallback') inferred from
# SOURCES.txt (top_level.txt and installed-files.txt is missing)
assert
import_names_from_package
(
'sources_fallback-pkg'
)
==
{
'sources_fallback'
}
class
EditableDistributionTest
(
fixtures
.
DistInfoPkgEditable
,
unittest
.
TestCase
):
def
test_origin
(
self
):
dist
=
Distribution
.
from_name
(
'distinfo-pkg'
)
assert
dist
.
origin
.
url
.
endswith
(
'.whl'
)
assert
dist
.
origin
.
archive_info
.
hashes
.
sha256
Back
|
FazBrowse Home
|
New Git URL