Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/iris/tests/unit/fileformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
# This file is part of Iris and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
"""Unit tests for the :mod:`iris.fileformats` package."""

import pytest
from pytest_mock import MockerFixture


class MockerMixin:
mocker: MockerFixture

@pytest.fixture(autouse=True)
def _mocker_mixin_setup(self, mocker):
self.mocker = mocker
34 changes: 12 additions & 22 deletions lib/iris/tests/unit/fileformats/pp/test_PPDataProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,23 @@
# See LICENSE in the root of the repository for full licensing details.
"""Unit tests for the `iris.fileformats.pp.PPDataProxy` class."""

# Import iris.tests first so that some things can be initialised before
# importing anything else.
import iris.tests as tests # isort:skip

from unittest import mock

from iris.fileformats.pp import PPDataProxy, SplittableInt


class Test_lbpack(tests.IrisTest):
def test_lbpack_SplittableInt(self):
lbpack = mock.Mock(spec_set=SplittableInt)
class Test_lbpack:
def test_lbpack_splittable_int(self, mocker):
lbpack = mocker.Mock(spec_set=SplittableInt)
proxy = PPDataProxy(None, None, None, None, None, lbpack, None, None)
self.assertEqual(proxy.lbpack, lbpack)
self.assertIs(proxy.lbpack, lbpack)
assert proxy.lbpack == lbpack
assert proxy.lbpack is lbpack

def test_lbpack_raw(self):
lbpack = 4321
proxy = PPDataProxy(None, None, None, None, None, lbpack, None, None)
self.assertEqual(proxy.lbpack, lbpack)
self.assertIsNot(proxy.lbpack, lbpack)
self.assertIsInstance(proxy.lbpack, SplittableInt)
self.assertEqual(proxy.lbpack.n1, lbpack % 10)
self.assertEqual(proxy.lbpack.n2, lbpack // 10 % 10)
self.assertEqual(proxy.lbpack.n3, lbpack // 100 % 10)
self.assertEqual(proxy.lbpack.n4, lbpack // 1000 % 10)


if __name__ == "__main__":
tests.main()
assert proxy.lbpack == lbpack
assert proxy.lbpack is not lbpack
assert isinstance(proxy.lbpack, SplittableInt)
assert proxy.lbpack.n1 == lbpack % 10
assert proxy.lbpack.n2 == lbpack // 10 % 10
assert proxy.lbpack.n3 == lbpack // 100 % 10
assert proxy.lbpack.n4 == lbpack // 1000 % 10
Loading
Loading