Beispiel #1
0
def test_getting_physical_type_exceptions(argument, exception):
    """
    Test that `get_physical_type` raises appropriate exceptions when
    provided with invalid arguments.
    """
    with pytest.raises(exception):
        physical.get_physical_type(argument)
Beispiel #2
0
def test_get_physical_type_equivalent_pairs(unit1, unit2):
    """
    Test that `get_physical_type` retrieves the same `PhysicalType`
    instances for equivalent physical types, except for unknown types
    which are not cataloged.
    """
    physical_type1 = physical.get_physical_type(unit1)
    physical_type2 = physical.get_physical_type(unit2)
    assert physical_type1 == physical_type2
    if physical_type1 != "unknown":
        assert physical_type1 is physical_type2
Beispiel #3
0
 def teardown_method(self):
     """
     Remove the definitions of the physical types that were added
     using `def_physical_unit` for testing purposes.
     """
     for unit in [self.weird_unit, self.strange_unit]:
         physical_type = physical.get_physical_type(unit)
         if physical_type != "unknown":
             self._undef_physical_type(unit)
         assert unit.physical_type == "unknown", (
             f"the physical type for {unit}, which was added for"
             f"testing, was not deleted.")
Beispiel #4
0
def test_getting_physical_type(physical_type_representation,
                               physical_type_name):
    """Test different ways of getting a physical type."""
    physical_type = physical.get_physical_type(physical_type_representation)
    assert isinstance(physical_type, physical.PhysicalType)
    assert physical_type == physical_type_name