예제 #1
0
 def dbc_attributes(self):
     # type: () -> _dbc_attributes.DbcAttributeCollection
     """:any:`nixnet.database._dbc_attributes.DbcAttributeCollection`: Access the frame's DBC attributes."""
     if self._dbc_attributes is None:
         self._dbc_attributes = _dbc_attributes.DbcAttributeCollection(
             self._handle)
     return self._dbc_attributes
예제 #2
0
 def dbc_attributes(self):
     # type: () -> _dbc_attributes.DbcAttributeCollection
     """:any:`DbcAttributeCollection`: Access the ECU's DBC attributes."""
     if self._dbc_attributes is None:
         self._dbc_attributes = _dbc_attributes.DbcAttributeCollection(
             self._handle)
     return self._dbc_attributes
예제 #3
0
def test_dbc_attributes():
    dbc_attributes120 = _dbc_attributes.DbcAttributeCollection(120)
    dbc_attributes130_1 = _dbc_attributes.DbcAttributeCollection(130)
    dbc_attributes130_2 = _dbc_attributes.DbcAttributeCollection(130)

    # test dunders
    assert str(dbc_attributes120) == 'DbcAttributeCollection(handle=120)'
    assert dbc_attributes130_1 == dbc_attributes130_2
    assert dbc_attributes130_1 != dbc_attributes120
    assert len({dbc_attributes120, dbc_attributes130_1, dbc_attributes130_2}) == 2  # testing `__hash__`
    assert len(dbc_attributes120) == 0
    for key in dbc_attributes120:
        print(dbc_attributes120[key])
    with pytest.raises(KeyError):
        print(dbc_attributes120[''])
    with pytest.raises(TypeError):
        print(dbc_attributes120[5])

    # test container
    assert sorted(dbc_attributes120.keys()) == []
    assert sorted(dbc_attributes120.values()) == []
    assert sorted(dbc_attributes120.items()) == []