From 9215f56ee8981af86d38fcea841b9a783203e5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?= Date: Tue, 19 Nov 2024 22:55:26 +0100 Subject: [PATCH] Test reading of > v4 Oxford binary files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- tests/test_io/test_oxford_binary.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_io/test_oxford_binary.py b/tests/test_io/test_oxford_binary.py index 7e74b88e..67cf2cf1 100644 --- a/tests/test_io/test_oxford_binary.py +++ b/tests/test_io/test_oxford_binary.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with kikuchipy. If not, see . +import os + import dask.array as da import numpy as np import pytest @@ -113,3 +115,30 @@ def test_guess_number_of_patterns(self, oxford_binary_file, n_patterns): with open(oxford_binary_file.name, mode="rb") as f: fox = OxfordBinaryFileReader(f) assert fox.n_patterns == n_patterns + + @pytest.mark.parametrize( + "oxford_binary_file", + [ + ((2, 3), (50, 50), np.uint8, 5, False, True), + ((2, 3), (50, 50), np.uint8, 6, False, True), + ], + indirect=["oxford_binary_file"], + ) + def test_version_5(self, oxford_binary_file): + with open(oxford_binary_file.name, mode="rb") as f: + fox = OxfordBinaryFileReader(f) + assert fox.n_patterns == 6 + + @pytest.mark.parametrize( + "oxford_binary_file, file_size", + [ + (((2, 3), (50, 50), np.uint8, 5, False, True), 15309), + (((2, 3), (50, 50), np.uint8, 4, False, True), 15261), + ], + indirect=["oxford_binary_file"], + ) + def test_estimated_file_size(self, oxford_binary_file, file_size): + with open(oxford_binary_file.name, mode="rb") as f: + fox = OxfordBinaryFileReader(f) + assert fox.get_estimated_file_size() == file_size + assert os.path.getsize(oxford_binary_file.name) == file_size