Skip to content

Commit b31922f

Browse files
authored
Cleanup conftest, remove LocalOutputFile (#468)
1 parent 339ba53 commit b31922f

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

tests/conftest.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
List,
4343
Optional,
4444
)
45-
from urllib.parse import urlparse
4645

4746
import boto3
4847
import pytest
@@ -57,8 +56,6 @@
5756
GCS_PROJECT_ID,
5857
GCS_TOKEN,
5958
GCS_TOKEN_EXPIRES_AT_MS,
60-
OutputFile,
61-
OutputStream,
6259
fsspec,
6360
load_file_io,
6461
)
@@ -88,7 +85,7 @@
8885
import pyarrow as pa
8986
from moto.server import ThreadedMotoServer # type: ignore
9087

91-
from pyiceberg.io.pyarrow import PyArrowFile, PyArrowFileIO
88+
from pyiceberg.io.pyarrow import PyArrowFileIO
9289

9390

9491
def pytest_collection_modifyitems(items: List[pytest.Item]) -> None:
@@ -1456,40 +1453,6 @@ def simple_map() -> MapType:
14561453
return MapType(key_id=19, key_type=StringType(), value_id=25, value_type=DoubleType(), value_required=False)
14571454

14581455

1459-
class LocalOutputFile(OutputFile):
1460-
"""An OutputFile implementation for local files (for test use only)."""
1461-
1462-
def __init__(self, location: str) -> None:
1463-
parsed_location = urlparse(location) # Create a ParseResult from the uri
1464-
if (
1465-
parsed_location.scheme and parsed_location.scheme != "file"
1466-
): # Validate that an uri is provided with a scheme of `file`
1467-
raise ValueError("LocalOutputFile location must have a scheme of `file`")
1468-
elif parsed_location.netloc:
1469-
raise ValueError(f"Network location is not allowed for LocalOutputFile: {parsed_location.netloc}")
1470-
1471-
super().__init__(location=location)
1472-
self._path = parsed_location.path
1473-
1474-
def __len__(self) -> int:
1475-
"""Return the length of an instance of the LocalOutputFile class."""
1476-
return os.path.getsize(self._path)
1477-
1478-
def exists(self) -> bool:
1479-
return os.path.exists(self._path)
1480-
1481-
def to_input_file(self) -> "PyArrowFile":
1482-
from pyiceberg.io.pyarrow import PyArrowFileIO
1483-
1484-
return PyArrowFileIO().new_input(location=self.location)
1485-
1486-
def create(self, overwrite: bool = False) -> OutputStream:
1487-
output_file = open(self._path, "wb" if overwrite else "xb")
1488-
if not issubclass(type(output_file), OutputStream):
1489-
raise TypeError("Object returned from LocalOutputFile.create(...) does not match the OutputStream protocol.")
1490-
return output_file
1491-
1492-
14931456
@pytest.fixture(scope="session")
14941457
def generated_manifest_entry_file(avro_schema_manifest_entry: Dict[str, Any]) -> Generator[str, None, None]:
14951458
from fastavro import parse_schema, writer

0 commit comments

Comments
 (0)