Esempio n. 1
0
    def test_04(self):
        """
        Test Case 04:
        Create an already existing directory with ``exist_ok`` set to False

        Test is passed if :py:exc:`OSError` is raised
        """
        td = tempfile.mkdtemp()
        with self.assertRaises(OSError):
            comp_makedirs(td, exist_ok=False)
        shutil.rmtree(td)
Esempio n. 2
0
    def test_01(self):
        """
        Test Case 01:
        Create a yet non-existing directory

        Test is passed if directory is created.
        """
        td = tempfile.mkdtemp()
        target = os.path.join(td, 'testpath')
        comp_makedirs(target)
        self.assertTrue(os.path.exists(target) and os.path.isdir(target))
        shutil.rmtree(td)
Esempio n. 3
0
    def test_02(self):
        """
        Test Case 02:
        Create an already existing directory with the same mode and ``exist_ok`` set to True

        Test is passed if no exception is raised.
        """
        td = tempfile.mkdtemp()
        mode = stat.S_IMODE(os.stat(td).st_mode)
        flag = True
        try:
            comp_makedirs(td, mode=mode, exist_ok=True)
        except OSError:
            flag = False
        shutil.rmtree(td)
        self.assertTrue(flag)