예제 #1
0
    def test_removes_existing_tempdir_with_its_content_and_creates_new_one(self):
        tempdir.make()
        os.mkdir(os.path.join(tempdir.path, 'aDir'))
        assert os.listdir(tempdir.path)         # assert is-not-empty

        tempdir.make()
        assert not os.listdir(tempdir.path)     # assert is-empty
예제 #2
0
def templates(directory, title):
    tempdir.make()
    context = {'title': title}
    template_names = env.list_templates()
    generate(template_names, context)
    dst_path = os.path.abspath(directory)
    tempdir.copy_files(template_names, dst_path)
    success_message(dst_path)
    tempdir.remove()
예제 #3
0
    def test_copies_files_from_tempdir_to_not_existing_dir(self):
        tempdir.make()

        file1 = 'file1'
        file2 = 'file2'
        open(os.path.join(tempdir.path, file1), 'w').close()
        open(os.path.join(tempdir.path, file2), 'w').close()

        tempdir.copy_files([file1, file2], self.dst_dir)

        assert os.path.isfile(os.path.join(self.dst_dir, file1))
        assert os.path.isfile(os.path.join(self.dst_dir, file2))
예제 #4
0
 def test_removes_tempdir(self):
     tempdir.make()
     tempdir.remove()
     assert not os.path.exists(tempdir.path)
예제 #5
0
 def test_removes_existing_file_that_has_name_of_tempdir_and_creates_tempdir(self):
     open(tempdir.dirname, 'w').close()
     assert os.path.isfile(tempdir.path)
     tempdir.make()
     assert os.path.isdir(tempdir.path)
예제 #6
0
 def test_creates_empty_tempdir(self):
     tempdir.make()
     assert os.path.exists(tempdir.path)
     assert not os.listdir(tempdir.path)     # assert is-empty