From b01bf579fd50cbc1a90e54ad55f828857b4bf9a2 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Sat, 21 Jul 2012 22:49:12 +0100 Subject: Create parent directories. --- lib/fixtures/tests/_fixtures/test_filetree.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/fixtures/tests') diff --git a/lib/fixtures/tests/_fixtures/test_filetree.py b/lib/fixtures/tests/_fixtures/test_filetree.py index 2da6ff6..c0f2c7e 100644 --- a/lib/fixtures/tests/_fixtures/test_filetree.py +++ b/lib/fixtures/tests/_fixtures/test_filetree.py @@ -166,3 +166,13 @@ class TestCreateNormalShape(TestCase): self.assertThat(os.path.join(path, 'a'), DirExists()) self.assertThat(os.path.join(path, 'b'), DirExists()) + def test_creates_parent_directories(self): + # If the parents of a file or directory don't exist, they get created + # too. + path = self.useFixture(TempDir()).path + create_normal_shape(path, [('a/b/', None), ('c/d.txt', 'text')]) + self.assertThat(path, DirContains(['a', 'c'])) + self.assertThat(os.path.join(path, 'a'), DirContains('b')) + self.assertThat(os.path.join(path, 'a', 'b'), DirExists()) + self.assertThat(os.path.join(path, 'c'), DirExists()) + self.assertThat(os.path.join(path, 'c', 'd.txt'), FileContains('text')) -- cgit v1.2.1