Example #1
0
    def init_environment(self,
                         test_dir=System.get_long_path(tempfile.mkdtemp()),
                         curr_dir=None):
        self._test_dir = System.realpath(test_dir)
        self._proj_dir = 'proj'
        self._test_git_dir = os.path.join(self._test_dir, self._proj_dir)
        self._old_curr_dir_abs = System.realpath(os.curdir)

        if os.path.exists(self._test_dir):
            rmtree(self._test_dir)

        if curr_dir:
            self._curr_dir = System.realpath(curr_dir)
        else:
            self._curr_dir = self._test_git_dir

        if not os.path.exists(self._curr_dir):
            os.makedirs(self._curr_dir)

        if not os.path.isdir(self._test_git_dir):
            os.makedirs(self._test_git_dir)

        data_dir = os.path.join(self._test_git_dir, 'data')
        cache_dir = os.path.join(self._test_git_dir, ConfigI.CONFIG_DIR,
                                 ConfigI.CACHE_DIR)
        state_dir = os.path.join(self._test_git_dir, ConfigI.CONFIG_DIR,
                                 ConfigI.STATE_DIR)

        os.makedirs(data_dir)
        os.makedirs(cache_dir)
        os.makedirs(state_dir)

        os.chdir(self._curr_dir)
Example #2
0
    def test_rmtree(self):
        root = 'testdir'

        os.makedirs(root + '/subdir')
        with open(root + '/file1', 'w+') as f:
            f.write('file1contents')
        with open(root + '/subdir/file2', 'w+') as f:
            f.write('file2contents')

        utils.rmtree(root)
        self.assertFalse(os.path.exists(root))
Example #3
0
 def tearDown(self):
     rmtree(self.test_dir)
     os.chdir(self._old_curr_dir_abs)
Example #4
0
 def tearDown(self):
     if self._old_curr_dir_abs:
         os.chdir(self._old_curr_dir_abs)
     if self._test_git_dir:
         rmtree(self._test_dir)
     pass