diff --git a/test/test_streamlayerformat.py b/test/test_streamlayerformat.py index 056afa4ce..f675438c1 100644 --- a/test/test_streamlayerformat.py +++ b/test/test_streamlayerformat.py @@ -40,9 +40,10 @@ class TestStreamLayerMerger(unittest.TestCase): with tarfile.open(fileobj=StringIO(squashed), mode='r:*') as tar: try: member = tar.getmember(filename) - self.fail('Filename %s found' % filename) - except: - pass + except Exception as ex: + return + + self.fail('Filename %s found' % filename) def test_single_layer(self): tar_layer = self.create_layer( @@ -122,11 +123,11 @@ class TestStreamLayerMerger(unittest.TestCase): def test_deleted_in_lower_layer(self): third_layer = self.create_layer( - another_file = 'bar') + deleted_file = 'bar') second_layer = self.create_layer( some_file = 'foo', - another_file = None, + deleted_file = None, third_file = 'meh') first_layer = self.create_layer( @@ -137,7 +138,9 @@ class TestStreamLayerMerger(unittest.TestCase): self.assertHasFile(squashed, 'some_file', 'foo') self.assertHasFile(squashed, 'third_file', 'meh') self.assertHasFile(squashed, 'top_file', 'top') - self.assertDoesNotHaveFile(squashed, 'another_file') + self.assertDoesNotHaveFile(squashed, 'deleted_file') + + if __name__ == '__main__': unittest.main() diff --git a/util/aufs.py b/util/aufs.py index e1ffb5b4a..b85fc31be 100644 --- a/util/aufs.py +++ b/util/aufs.py @@ -28,4 +28,7 @@ def get_deleted_prefix(filepath): return None dirname = os.path.dirname(filepath) + if not dirname: + return deleted_filename + return os.path.join('/', dirname, deleted_filename)