Skip to content

Commit

Permalink
added test for NamedTuple getattribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Galvin committed Jan 13, 2024
1 parent 67290fe commit 9e2db12
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Items related to test functions in the validation stage of flint
"""
from pathlib import Path
from typing import NamedTuple

import numpy as np
import pkg_resources
Expand Down Expand Up @@ -31,3 +32,22 @@ def test_rms_image_info(rms_path):
assert np.isclose(0.00015135764, rms_info.minimum)
assert np.isclose(0.0001518184, rms_info.maximum)
assert np.isclose(1.1098655e-07, rms_info.std)

def test_expected_namedtuple_get():
"""This is a simple test to ensure the behavour of
NamedTuple.__getattribute__ remains OK. This is currently
used in the validation plotting to iterate over known
surveys
"""
class Example(NamedTuple):
a: int
b: str
c: float

test = Example(a=1, b='123', c=1.23)

assert test.__getattribute__('a') == 1
assert test.__getattribute__('b') == '123'
assert test.__getattribute__('c') == 1.23


0 comments on commit 9e2db12

Please sign in to comment.