示例#1
0
    def test_on_uncreatable_file(self):
        with tempfile.TemporaryDirectory() as parent_directory:
            # Create a file name with a char forbidden in POSIX and WIN*
            forbidden_char = "/"
            file_name = "SOMEDIR{}".format(forbidden_char)
            file_path = os.path.join(parent_directory, file_name)

            # Assert that the forbidden character prohibited path creation
            self.assertFalse(is_existing_or_creatable_path(file_path))
示例#2
0
 def test_on_nonexisting_creatable_file(self):
     # Create and delete a temp file so we know that it is a valid path
     file1 = tempfile.mkstemp()[1]
     os.remove(file1)
     self.assertTrue(is_existing_or_creatable_path(file1))
示例#3
0
 def test_on_nonexisting_creatable_dir(self):
     # Create and delete a temp directory so we know that it is a valid path
     dir1 = tempfile.mkdtemp()
     os.rmdir(dir1)
     self.assertTrue(is_existing_or_creatable_path(dir1))
示例#4
0
 def test_on_existing_file(self):
     with tempfile.NamedTemporaryFile() as file1:
         self.assertTrue(is_existing_or_creatable_path(file1.name))
示例#5
0
 def test_on_existing_dir(self):
     with tempfile.TemporaryDirectory() as dir1:
         self.assertTrue(is_existing_or_creatable_path(dir1))