Example #1
0
    def test_make_dirs_exists(self):
        exists_calls = []

        def _exists(*args):
            exists_calls.append(args)
            return True

        util.exists = _exists
        util.make_dirs('test')
        self.assertEqual(exists_calls, [('test',)])
        self.assertEqual(self.makedirs_calls, [])
Example #2
0
    def test_make_dirs_did_not_exist_but_then_did(self):
        makedirs_calls = []

        def _makedirs(*args):
            makedirs_calls.append(args)
            err = OSError('testing')
            err.errno = util.EEXIST
            raise err

        util.makedirs = _makedirs
        util.make_dirs('test')
        self.assertEqual(self.exists_calls, [('test',)])
        self.assertEqual(makedirs_calls, [('test', 0777)])
Example #3
0
    def test_make_dirs_other_error(self):
        makedirs_calls = []

        def _makedirs(*args):
            makedirs_calls.append(args)
            raise OSError('testing')

        util.makedirs = _makedirs
        exc = None
        try:
            util.make_dirs('test')
        except Exception, err:
            exc = err
Example #4
0
    def test_make_dirs_other_error(self):
        makedirs_calls = []

        def _makedirs(*args):
            makedirs_calls.append(args)
            raise OSError('testing')

        util.makedirs = _makedirs
        exc = None
        try:
            util.make_dirs('test')
        except Exception as err:
            exc = err
        self.assertEqual(str(exc), 'testing')
        self.assertEqual(self.exists_calls, [('test',)])
        self.assertEqual(makedirs_calls, [('test', 0777)])
Example #5
0
 def test_make_dirs(self):
     util.make_dirs('test')
     self.assertEqual(self.exists_calls, [('test',)])
     self.assertEqual(self.makedirs_calls, [('test', 0777)])