Skip to content

Commit

Permalink
Merge pull request #217 from kwlzn/kwlzn/113_breakage
Browse files Browse the repository at this point in the history
Add a test to reveal breakage outlined in #216 and revert 1fe5a4e.
  • Loading branch information
kwlzn committed Mar 12, 2016
2 parents 37242d3 + f07ad9e commit 12e4bf7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pex/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class FixedEggMetadata(pkg_resources.EggMetadata):
@classmethod
def normalized_elements(cls, path):
path_split = path.split('/')
while path_split and path_split[-1] in ('', '.'):
while path_split[-1] in ('', '.'):
path_split.pop(-1)
return path_split

Expand All @@ -136,9 +136,10 @@ def _fn(self, base, resource_name):
return '/'.join(self.normalized_elements(original_fn))

def _zipinfo_name(self, fspath):
# Make sure to not normalize the zip_pre - that's an OS-native path.
if fspath.startswith(self.zip_pre):
return '/'.join(self.normalized_elements(fspath[len(self.zip_pre):]))
fspath = self.normalized_elements(fspath)
zip_pre = self.normalized_elements(self.zip_pre)
if fspath[:len(zip_pre)] == zip_pre:
return '/'.join(fspath[len(zip_pre):])
assert "%s is not a subpath of %s" % (fspath, self.zip_pre)


Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,11 @@ def test_named_temporary_file():
assert new_fp.read() == 'hi'

assert not os.path.exists(name)


def test_distributionhelper_egg_assert():
d = DistributionHelper.distribution_from_path(
'./tests/example_packages/setuptools-18.0.1-py2.7.egg',
'setuptools'
)
assert len(d.resource_listdir('/')) > 3

0 comments on commit 12e4bf7

Please sign in to comment.