Skip to content

Commit dea73b2

Browse files
committed
Add test for result none
1 parent 50f5270 commit dea73b2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/io/test_fileformat.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,31 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
from typing import Any
19+
20+
import pytest
21+
22+
from pyiceberg.io.fileformat import DataFileStatistics, FileFormatWriter
23+
1824

1925
def test_backward_compat_import() -> None:
2026
"""DataFileStatistics can still be imported from pyiceberg.io.pyarrow."""
2127
from pyiceberg.io.fileformat import DataFileStatistics as dFS # noqa: F401
2228
from pyiceberg.io.pyarrow import DataFileStatistics # noqa: F401
2329

2430
assert DataFileStatistics is dFS
31+
32+
33+
def test_result_before_close_raises() -> None:
34+
"""Calling result before close should raise an error."""
35+
36+
class _DummyWriter(FileFormatWriter):
37+
def write(self, table: Any) -> None:
38+
pass
39+
40+
def close(self) -> DataFileStatistics:
41+
raise NotImplementedError
42+
43+
writer = _DummyWriter()
44+
with pytest.raises(RuntimeError, match="Writer has not been closed yet"):
45+
writer.result()

0 commit comments

Comments
 (0)