summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/fixtures/_fixtures/filetree.py7
-rw-r--r--lib/fixtures/tests/_fixtures/test_filetree.py8
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/fixtures/_fixtures/filetree.py b/lib/fixtures/_fixtures/filetree.py
index 3c9bc3a..5fee966 100644
--- a/lib/fixtures/_fixtures/filetree.py
+++ b/lib/fixtures/_fixtures/filetree.py
@@ -45,14 +45,11 @@ class FileTree(Fixture):
if isinstance(description, basestring):
name = description
else:
- try:
- name, contents = description
- except ValueError:
- name = description[0]
+ name = description[0]
name = os.path.join(path, name)
if name[-1] == '/':
os.mkdir(name)
else:
f = open(name, 'w')
- f.write(contents)
+ f.write(description[1])
f.close()
diff --git a/lib/fixtures/tests/_fixtures/test_filetree.py b/lib/fixtures/tests/_fixtures/test_filetree.py
index fdbfd28..aab1fb2 100644
--- a/lib/fixtures/tests/_fixtures/test_filetree.py
+++ b/lib/fixtures/tests/_fixtures/test_filetree.py
@@ -30,10 +30,13 @@ from fixtures.tests.helpers import NotHasattr
class TestFileTree(TestCase):
def test_no_path_at_start(self):
+ # FileTree fixture doesn't create a path at the beginning.
fixture = FileTree([])
self.assertThat(fixture, NotHasattr('path'))
def test_creates_directory(self):
+ # It creates a temporary directory once set up. That directory is
+ # removed at cleanup.
fixture = FileTree([])
fixture.setUp()
try:
@@ -43,6 +46,8 @@ class TestFileTree(TestCase):
self.assertThat(fixture.path, Not(DirExists()))
def test_creates_files(self):
+ # When given a list of file specifications, it creates those files
+ # underneath the temporary directory.
fixture = FileTree([('a', 'foo'), ('b', 'bar')])
with fixture:
path = fixture.path
@@ -51,6 +56,7 @@ class TestFileTree(TestCase):
self.assertThat(os.path.join(path, 'b'), FileContains('bar'))
def test_creates_directories(self):
+ # When given directory specifications, it creates those directories.
fixture = FileTree([('a/', None), ('b/',)])
with fixture:
path = fixture.path
@@ -59,6 +65,8 @@ class TestFileTree(TestCase):
self.assertThat(os.path.join(path, 'b'), DirExists())
def test_simpler_directory_syntax(self):
+ # Directory specifications don't have to be tuples. They can be single
+ # strings.
fixture = FileTree(['a/'])
with fixture:
path = fixture.path