def test_gpibusbcomm_address(): # Create our communicator comm = GPIBCommunicator(mock.MagicMock(), 1) port_name = mock.PropertyMock(return_value="/dev/address") type(comm._file).address = port_name # Check that our address function is working eq_(comm.address, (1, "/dev/address")) port_name.assert_called_with() # Able to set GPIB address comm.address = 5 eq_(comm._gpib_address, 5) # Able to set address with a list comm.address = [6, "/dev/foobar"] # pylint: disable=redefined-variable-type eq_(comm._gpib_address, 6) port_name.assert_called_with("/dev/foobar")
def test_gpibusbcomm_address(): # Create our communicator comm = GPIBCommunicator(mock.MagicMock(), 1) port_name = mock.PropertyMock(return_value="/dev/address") type(comm._file).address = port_name # Check that our address function is working eq_(comm.address, (1, "/dev/address")) port_name.assert_called_with() # Able to set GPIB address comm.address = 5 eq_(comm._gpib_address, 5) # Able to set address with a list comm.address = [6, "/dev/foobar"] eq_(comm._gpib_address, 6) port_name.assert_called_with("/dev/foobar")
def test_gpibusbcomm_address(): # Create our communicator comm = GPIBCommunicator(mock.MagicMock(), 1) port_name = mock.PropertyMock(return_value="/dev/address") type(comm._file).address = port_name # Check that our address function is working assert comm.address == (1, "/dev/address") port_name.assert_called_with() # Able to set GPIB address comm.address = 5 assert comm._gpib_address == 5 # Able to set address with a list comm.address = [6, "/dev/foobar"] assert comm._gpib_address == 6 port_name.assert_called_with("/dev/foobar")
def test_gpibusbcomm_address_wrong_type(): comm = GPIBCommunicator(mock.MagicMock(), 1) comm.address = "derp"
def test_gpibusbcomm_address_out_of_range(): comm = GPIBCommunicator(mock.MagicMock(), 1) comm.address = 31
def test_gpibusbcomm_address_wrong_type(): with pytest.raises(TypeError): comm = GPIBCommunicator(mock.MagicMock(), 1) comm.address = "derp"
def test_gpibusbcomm_address_out_of_range(): with pytest.raises(ValueError): comm = GPIBCommunicator(mock.MagicMock(), 1) comm.address = 31