Changeset 9283


Ignore:
Timestamp:
3 Oct 2012, 21:36:14 (12 years ago)
Author:
Henrik Bettermann
Message:

Remove temporary dirs in tests.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
9 edited

Legend:

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

    r9271 r9283  
    9494        clearSite()
    9595        shutil.rmtree(self.dc_root)
     96        shutil.rmtree(self.workdir)
    9697
    9798class ACBatchProcessorTest(ACFullSetup):
     
    126127        self.csv_file = os.path.join(self.workdir, 'sample_batch_data.csv')
    127128        open(self.csv_file, 'wb').write(BATCH_SAMPLE_DATA)
    128         self.processor.doImport(self.csv_file, BATCH_HEADER_FIELDS)
     129        num, num_warns, fin_file, fail_file =  self.processor.doImport(
     130            self.csv_file, BATCH_HEADER_FIELDS)
     131        shutil.rmtree(os.path.dirname(fin_file))
    129132
    130133        self.processor = AccessCodeProcessor()
     
    175178        self.csv_file = os.path.join(self.workdir, 'sample_batch_data.csv')
    176179        open(self.csv_file, 'wb').write(BATCH_SAMPLE_DATA)
    177         self.processor.doImport(self.csv_file, BATCH_HEADER_FIELDS)
     180        num, num_warns, fin_file, fail_file =  self.processor.doImport(
     181            self.csv_file, BATCH_HEADER_FIELDS)
     182        shutil.rmtree(os.path.dirname(fin_file))
    178183
    179184        self.processor = AccessCodeProcessor()
     
    182187        num, num_warns, fin_file, fail_file =  self.processor.doImport(
    183188            self.csv_file, AC_HEADER_FIELDS)
     189        shutil.rmtree(os.path.dirname(fin_file))
    184190
    185191        self.assertEqual(self.app['accesscodes']['HOS-1'].used_num, 1)
     
    192198        num, num_warns, fin_file, fail_file =  self.processor.doImport(
    193199            self.csv_file, AC_HEADER_FIELDS_UPDATE, 'update')
    194         fin_file = open(fin_file).read()
    195200        self.assertEqual(num_warns,0)
    196201        self.assertEqual(
     
    216221        self.assertEqual(self.app['accesscodes']['CLR-1'].used_num, 1)
    217222        self.assertEqual(self.app['accesscodes']['CLR-1'].disabled_num, 0)
     223        shutil.rmtree(os.path.dirname(fin_file))
    218224        return
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r9202 r9283  
    434434        return
    435435
     436    def tearDown(self):
     437        super(ExportTests, self).tearDown()
     438        clearSite()
     439        shutil.rmtree(os.path.dirname(self.outfile))
     440
    436441class HostelProcessorTest(HostelsFullSetup):
    437442
     
    441446        self.processor = HostelProcessor()
    442447        self.workdir = tempfile.mkdtemp()
    443         self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv')
     448        self.csv_file = os.path.join(self.workdir, 'sample_hostel_data.csv')
    444449        open(self.csv_file, 'wb').write(HOSTEL_SAMPLE_DATA)
    445450        num, num_warns, fin_file, fail_file = self.processor.doImport(
     
    462467            in logcontent)
    463468        shutil.rmtree(os.path.dirname(fin_file))
    464         return
     469        shutil.rmtree(self.workdir)
     470        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9282 r9283  
    576576class StudentVerdictProcessorTest(StudentImportExportSetup):
    577577
    578 
    579578    def setUp(self):
    580579        super(StudentVerdictProcessorTest, self).setUp()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9273 r9283  
    13361336        self.student['studycourse'].current_level = 999
    13371337        IWorkflowState(self.student).setState('school fee paid')
    1338         self.certificate.study_mode = 'pg_ft'
    13391338        self.browser.open(self.login_path)
    13401339        self.browser.getControl(name="form.login").value = self.student_id
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_imagestorage.py

    r7811 r9283  
    274274    def test_default_handler_create_file(self):
    275275        # we can use the default handler to store files
    276         fs = ExtFileStore()
     276        fs = ExtFileStore(root=self.workdir)
    277277        result = fs.createFile('sample.txt', StringIO('sample text'))
    278278        self.assertEqual(result.data, 'sample.txt')
     
    282282    def test_default_handler_get_file(self):
    283283        # we can get files stored by the default handler
    284         fs = ExtFileStore()
     284        fs = ExtFileStore(root=self.workdir)
    285285        fs.createFile('sample.txt', StringIO('sample text'))
    286286        result1 = fs.getFile('sample.txt')
     
    292292    def test_customized_handler_create_file(self):
    293293        # we can use registered filename handlers
    294         fs = ExtFileStore()
     294        fs = ExtFileStore(root=self.workdir)
    295295        result = fs.createFile(
    296296            '__MYMARKER__sample.txt', StringIO('sample text'))
     
    302302        # when we create a file of img type, the filename ext is taken
    303303        # from input file.
    304         fs = ExtFileStore()
     304        fs = ExtFileStore(root=self.workdir)
    305305        result = fs.createFile(
    306306            '__MYMARKER__sample_img.png', StringIO('sample text'))
     
    312312        # we consider registered filename handlers when asking for
    313313        # stored files.
    314         fs = ExtFileStore()
     314        fs = ExtFileStore(root=self.workdir)
    315315        fs.createFile('__MYMARKER__sample.txt', StringIO('sample text'))
    316316        result1 = fs.getFile('__MYMARKER__sample.txt')
     
    325325        # if we register a file name chooser, we can also get a file
    326326        # by context and attribute
    327         fs = ExtFileStore()
     327        fs = ExtFileStore(root=self.workdir)
    328328        context = CustomContext()
    329329        file_id1 = IFileStoreNameChooser(context).chooseName()
    330330        file_id2 = IFileStoreNameChooser(context).chooseName(attr='img')
    331331        file_id3 = IFileStoreNameChooser(context).chooseName(attr='doc')
    332         fs = ExtFileStore()
     332        fs = ExtFileStore(root=self.workdir)
    333333        # create three files for a single context, each which
    334334        # different content
     
    365365    def test_delete_file(self):
    366366        # we can remove stored files from storage
    367         fs = ExtFileStore()
     367        fs = ExtFileStore(root=self.workdir)
    368368        # First, we store a file in file store
    369369        fs.createFile('sample.txt', StringIO('sample text'))
     
    380380        # if we register a file name chooser, we can also delete a file
    381381        # by context and attribute
    382         fs = ExtFileStore()
     382        fs = ExtFileStore(root=self.workdir)
    383383        context = CustomContext()
    384384        file_id1 = IFileStoreNameChooser(context).chooseName()
    385385        file_id2 = IFileStoreNameChooser(context).chooseName(attr='img')
    386386        file_id3 = IFileStoreNameChooser(context).chooseName(attr='doc')
    387         fs = ExtFileStore()
     387        fs = ExtFileStore(root=self.workdir)
    388388        # create three files for a single context, each which
    389389        # different content
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py

    r9087 r9283  
    310310            'code=DEP2'
    311311            in logcontent)
     312        shutil.rmtree(os.path.dirname(fin_file))
    312313
    313314    def test_upload_import_reupload(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/userscontainer.txt

    r8787 r9283  
    7474    >>> list(myusers)
    7575    []
     76
     77Clean up:
     78
     79    >>> import shutil
     80    >>> shutil.rmtree(workdir)
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_batching.py

    r9217 r9283  
    392392
    393393    def __init__(self):
    394         dir_path = tempfile.mkdtemp()
    395         self.result = os.path.join(dir_path, 'fake.csv')
     394        self.dir_path = tempfile.mkdtemp()
     395        self.result = os.path.join(self.dir_path, 'fake.csv')
    396396        open(self.result, 'wb').write('a fake result')
    397397        return
     
    551551        self.assertEqual(result2, ('4', 'cave_exporter', 'bob'))
    552552        self.assertEqual(result3, None)
    553         return
     553        shutil.rmtree(fake_job.dir_path)
     554        return
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_logger.py

    r8492 r9283  
    194194        self.assertTrue('Warning 2' not in content1)
    195195        self.assertTrue(filename1 != filename2)
     196        shutil.rmtree(self.dc_root2)
    196197        return
    197198
Note: See TracChangeset for help on using the changeset viewer.