Ejemplo n.º 1
0
    def test_file_or_path_invalid_path(self, m):
        filename = "testfile_file_or_path_invalid_path_{}".format(uuid.uuid4().hex)

        # intentionally do not create file

        with self.assertRaises(IOError):
            handler, is_path = file_or_path(filename)
Ejemplo n.º 2
0
    def test_file_or_path_file(self, m):
        filename = "testfile_file_or_path_file_{}".format(uuid.uuid4().hex)

        try:
            # create file and pass it in directly
            with open(filename, "w+") as file:
                handler, is_path = file_or_path(file)

                self.assertFalse(is_path)
        finally:
            cleanup_file(filename)
Ejemplo n.º 3
0
    def test_file_or_path_valid_path(self, m):
        filename = "testfile_file_or_path_valid_path_{}".format(uuid.uuid4().hex)

        try:
            # create file and immediately close it
            open(filename, "w+").close()

            handler, is_path = file_or_path(filename)
            self.assertTrue(is_path)

            # close re-opened file
            handler.close()
        finally:
            cleanup_file(filename)