summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2012-07-22 10:27:52 +0100
committerJonathan Lange <jml@canonical.com>2012-07-22 10:27:52 +0100
commit642b5c9906dc8484b90ed326ab32e9ca419ff4c1 (patch)
treed97866852c54f48b1a621c6a754ce3739b0afcc3
parentf101fded8808791f0deb637675b126bfbdc602d5 (diff)
downloadfixtures-642b5c9906dc8484b90ed326ab32e9ca419ff4c1.tar.gz
Change the API to have *args.
-rw-r--r--lib/fixtures/_fixtures/tempdir.py13
-rw-r--r--lib/fixtures/tests/_fixtures/test_tempdir.py4
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/fixtures/_fixtures/tempdir.py b/lib/fixtures/_fixtures/tempdir.py
index 4c6df75..3af8d00 100644
--- a/lib/fixtures/_fixtures/tempdir.py
+++ b/lib/fixtures/_fixtures/tempdir.py
@@ -45,7 +45,18 @@ class TempDir(fixtures.Fixture):
self.path = tempfile.mkdtemp(dir=self.rootdir)
self.addCleanup(shutil.rmtree, self.path, ignore_errors=True)
- def make_tree(self, shape):
+ def make_tree(self, *shape):
+ """Make a tree of files and directories underneath this temp dir.
+
+ :param shape: A list of descriptions of files and directories to make.
+ Generally directories are described as ``"directory/"`` and
+ files are described as ``("filename", contents)``. Filenames can
+ also be specified without contents, in which case we'll make
+ something up.
+
+ Directories can also be specified as ``(directory, None)`` or
+ ``(directory,)``.
+ """
create_normal_shape(self.path, normalize_shape(shape))
diff --git a/lib/fixtures/tests/_fixtures/test_tempdir.py b/lib/fixtures/tests/_fixtures/test_tempdir.py
index 2f0c431..c253a68 100644
--- a/lib/fixtures/tests/_fixtures/test_tempdir.py
+++ b/lib/fixtures/tests/_fixtures/test_tempdir.py
@@ -92,7 +92,7 @@ class TestFileTree(testtools.TestCase):
# that doesn't matter. We'll create the directory first.
fixture = TempDir()
with fixture:
- fixture.make_tree(['a/b/', 'a/'])
+ fixture.make_tree('a/b/', 'a/')
path = fixture.path
self.assertThat(path, DirContains(['a']))
self.assertThat(os.path.join(path, 'a'), DirContains(['b']))
@@ -101,7 +101,7 @@ class TestFileTree(testtools.TestCase):
def test_not_even_creating_parents(self):
fixture = TempDir()
with fixture:
- fixture.make_tree(['a/b/foo.txt', 'c/d/e/'])
+ fixture.make_tree('a/b/foo.txt', 'c/d/e/')
path = fixture.path
self.assertThat(
os.path.join(path, 'a', 'b', 'foo.txt'),