MCPcopy
hub / github.com/docker/docker-py / test_tar_with_excludes

Method test_tar_with_excludes

tests/unit/utils_build_test.py:344–388  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

342
343class TarTest(unittest.TestCase):
344 def test_tar_with_excludes(self):
345 dirs = [
346 'foo',
347 'foo/bar',
348 'bar',
349 ]
350
351 files = [
352 'Dockerfile',
353 'Dockerfile.alt',
354 '.dockerignore',
355 'a.py',
356 'a.go',
357 'b.py',
358 'cde.py',
359 'foo/a.py',
360 'foo/b.py',
361 'foo/bar/a.py',
362 'bar/a.py',
363 ]
364
365 exclude = [
366 '*.py',
367 '!b.py',
368 '!a.go',
369 'foo',
370 'Dockerfile*',
371 '.dockerignore',
372 ]
373
374 expected_names = {
375 'Dockerfile',
376 '.dockerignore',
377 'a.go',
378 'b.py',
379 'bar',
380 'bar/a.py',
381 }
382
383 base = make_tree(dirs, files)
384 self.addCleanup(shutil.rmtree, base)
385
386 with tar(base, exclude=exclude) as archive:
387 tar_data = tarfile.open(fileobj=archive)
388 assert sorted(tar_data.getnames()) == sorted(expected_names)
389
390 def test_tar_with_empty_directory(self):
391 base = tempfile.mkdtemp()

Callers

nothing calls this directly

Calls 2

tarFunction · 0.90
make_treeFunction · 0.85

Tested by

no test coverage detected