From 4a7ce1b0a9d27924e37407f4ebb03ca546f04197 Mon Sep 17 00:00:00 2001 From: Theodore Chang <tlcfem@gmail.com> Date: Mon, 21 Oct 2024 18:08:56 +0200 Subject: [PATCH] Add test --- tests/metainfo/test_metainfo.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/metainfo/test_metainfo.py b/tests/metainfo/test_metainfo.py index 5e91c5c765..5f6e272541 100644 --- a/tests/metainfo/test_metainfo.py +++ b/tests/metainfo/test_metainfo.py @@ -675,9 +675,14 @@ class TestM1: test_quantity = Quantity(type=np.dtype('int32')) test_section = TestSection() - test_section.test_quantity = 12 - assert test_section.test_quantity == 12 - assert type(test_section.test_quantity) is np.int32 + + for value in [12, np.array([12], dtype=np.int32)]: + test_section.test_quantity = value + assert test_section.test_quantity == 12 + assert type(test_section.test_quantity) is np.int32 + + with pytest.raises(ValueError): + test_section.test_quantity = np.array([12, 13], dtype=np.int32) def test_scalar_float(self): class TestSection(MSection): -- GitLab