sys_path: order egg-link files for reproducible test results

This commit is contained in:
immerrr
2015-10-21 12:03:39 +03:00
parent f500457100
commit da4dbe81a9
2 changed files with 5 additions and 2 deletions

View File

@@ -35,7 +35,10 @@ def _get_sys_path_with_egglinks(sys_path):
result = [] result = []
for p in sys_path: for p in sys_path:
result.append(p) result.append(p)
for egg_link in glob.glob(os.path.join(p, '*.egg-link')): # pkg_resources does not define a specific order for egg-link files
# using os.listdir to enumerate them, we're sorting them to have
# reproducible tests.
for egg_link in sorted(glob.glob(os.path.join(p, '*.egg-link'))):
with open(egg_link) as fd: with open(egg_link) as fd:
for line in fd: for line in fd:
line = line.strip() line = line.strip()

View File

@@ -43,8 +43,8 @@ def test_get_venv_path(venv):
glob(pjoin(venv, 'lib', 'site-packages')))[0] glob(pjoin(venv, 'lib', 'site-packages')))[0]
ETALON = [ ETALON = [
site_pkgs, site_pkgs,
pjoin(site_pkgs, '.', 'relative', 'egg-link', 'path'),
pjoin('/path', 'from', 'egg-link'), pjoin('/path', 'from', 'egg-link'),
pjoin(site_pkgs, '.', 'relative', 'egg-link', 'path'),
pjoin(site_pkgs, 'dir-from-foo-pth'), pjoin(site_pkgs, 'dir-from-foo-pth'),
pjoin('/path', 'from', 'smth.py'), pjoin('/path', 'from', 'smth.py'),
pjoin('/path', 'from', 'smth.py:extend_path') pjoin('/path', 'from', 'smth.py:extend_path')