Ignore:
Timestamp:
4 Oct 2012, 09:48:56 (12 years ago)
Author:
uli
Message:

Minor cleanups, also remove the last remaining directory created in tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_imagestorage.py

    r9283 r9286  
    3535    IFileStoreNameChooser, IExtFileStore, IFileStoreHandler,)
    3636
    37 class HelperFuncsTests(unittest.TestCase):
    38 
    39     def setUp(self):
    40         self.workdir = tempfile.mkdtemp()
    41 
    42     def tearDown(self):
    43         shutil.rmtree(self.workdir)
    44 
    4537class FileStoreNameChooserTests(FunctionalTestCase):
    4638
     
    9385        verifyClass(IExtFileStore, ExtFileStore)
    9486        verifyObject(IExtFileStore, obj)
     87        self.root = obj.root # for cleanup
    9588        return
    9689
     
    10497
    10598    def test_create_instance(self):
     99        # we can create file stores with or without a root dir set
    106100        storage1 = ExtFileStore()
    107101        storage2 = ExtFileStore(root=self.workdir)
     
    227221        super(FunctionalExtFileStoreTests, self).setUp()
    228222        self.workdir = tempfile.mkdtemp()
     223        self.root = None
    229224        self.samplefile = os.path.join(self.workdir, 'sample')
    230225        self.otherfile = os.path.join(self.workdir, 'other')
     
    251246        self.fd2.close()
    252247        shutil.rmtree(self.workdir)
     248        if self.root is not None and os.path.exists(self.root):
     249            shutil.rmtree(self.root)
    253250        return
    254251
     
    325322        # if we register a file name chooser, we can also get a file
    326323        # by context and attribute
    327         fs = ExtFileStore(root=self.workdir)
    328324        context = CustomContext()
    329325        file_id1 = IFileStoreNameChooser(context).chooseName()
    330326        file_id2 = IFileStoreNameChooser(context).chooseName(attr='img')
    331327        file_id3 = IFileStoreNameChooser(context).chooseName(attr='doc')
    332         fs = ExtFileStore(root=self.workdir)
    333         # create three files for a single context, each which
    334         # different content
     328        # create three files for a single context, each with different
     329        # content
     330        fs = ExtFileStore(root=self.workdir)
    335331        fs.createFile(file_id1, StringIO('my sample 1'))
    336332        fs.createFile(file_id2, StringIO('my sample 2'))
Note: See TracChangeset for help on using the changeset viewer.