def test_read_return_value(self, mock_check_output): mock_check_output.return_value = "1\n" result = read(pin=1) self.assertEqual(result, 1, 'Result should be int(1).')
def test_read_wrong_pin(self, mock_check_output): with self.assertRaises(WrongPinNumber): read(pin=26) self.assertFalse(mock_check_output.called, "check_output shouldn't be called.")
def test_read_check_output(self, mock_check_output): read(pin=1) mock_check_output.assert_called_with('gpio -g read 1', shell=True)