code: def test_path_partition_parser_errors():
      # no field names for DIRECTORY path partitioning
      with pytest.raises(ValueError):
          PathPartitionParser.of(style=PartitionStyle.DIRECTORY)
      # explicit no field names for DIRECTORY path partitioning
      with pytest.raises(ValueError):
          PathPartitionParser.of(
              style=PartitionStyle.DIRECTORY, field_names=[]
          )
      # invalid path partitioning style
      with pytest.raises(ValueError):
          PathPartitionParser.of(style=None)
      # HIVE partition field name and field value length or order mismatch
      path_partition_parser = PathPartitionParser.of(
          style=PartitionStyle.HIVE,
          field_names=["foo", "bar"],
      )
      with pytest.raises(ValueError):
          path_partition_parser("foo=1/")
      with pytest.raises(ValueError):
          path_partition_parser("bar=1/foo=2/")
      with pytest.raises(ValueError):
          path_partition_parser("foo=1/bar=2/qux=3/")
      # ensure HIVE partition base directory is not considered a partition
      path_partition_parser = PathPartitionParser.of(
          style=PartitionStyle.HIVE,
          base_dir="foo=1",
          field_names=["foo", "bar"],
      )
      with pytest.raises(ValueError):
          path_partition_parser("foo=1/bar=2/")
      # DIRECTORY partition field name and field value length mismatch
      path_partition_parser = PathPartitionParser.of(
          style=PartitionStyle.DIRECTORY,
          field_names=["foo", "bar"],
      )
      with pytest.raises(ValueError):
          path_partition_parser("1/")
      with pytest.raises(ValueError):
          path_partition_parser("1/2/3/")
      # ensure DIRECTORY partition base directory is not considered a partition
      path_partition_parser = PathPartitionParser.of(
          style=PartitionStyle.DIRECTORY,
          base_dir="1",
          field_names=["foo", "bar"],
      )
      with pytest.raises(ValueError):
          path_partition_parser("1/2/")
  
imports: import json
  import os
  import posixpath
  from typing import Any, Callable, Dict, Iterator, List, Optional, Union
  import pandas
  import pyarrow
  import pyarrow
  import pytest
  from pyarrow.fs import FileType
  from pytest_lazyfixture import lazy_fixture
  import ray
  from ray.data.block import Block
  from ray.data.dataset import Dataset
  from ray.data.datasource import FileBasedDatasource, PathPartitionParser
  from ray.data.datasource.file_based_datasource import FileExtensionFilter, _resolve_paths_and_filesystem
  from ray.data.datasource.partitioning import Partitioning, PartitionStyle, PathPartitionFilter
  from ray.data.tests.conftest import *
  from ray.tests.conftest import *
label_desc: Use image node_id 10 for calling a global function with example usage: test_path_partition_parser_errors() without return types