test_fake.py
Go to the documentation of this file.
1 #! /usr/bin/python
2 """
3 test_xbee.py
4 
5 By Paul Malmsten, 2010
6 pmalmsten@gmail.com
7 
8 Tests fake device objects for proper functionality.
9 """
10 import unittest
11 from xbee.tests.Fake import FakeReadDevice
12 
13 class TestFakeReadDevice(unittest.TestCase):
14  """
15  FakeReadDevice class should work as intended to emluate a serial
16  port
17  """
18  def setUp(self):
19  """
20  Create a fake read device for each test
21  """
22  self.device = FakeReadDevice("test")
23 
25  """
26  reading one byte at a time should work as expected
27  """
28  self.assertEqual(self.device.read(), 't')
29  self.assertEqual(self.device.read(), 'e')
30  self.assertEqual(self.device.read(), 's')
31  self.assertEqual(self.device.read(), 't')
32 
34  """
35  reading multiple bytes at a time should work as expected
36  """
37  self.assertEqual(self.device.read(3), 'tes')
38  self.assertEqual(self.device.read(), 't')
39 
40  def test_read_too_many(self):
41  """
42  attempting to read too many bytes should raise an exception
43  """
44  self.assertRaises(ValueError, self.device.read, 5)
xbee.tests.Fake
Definition: Fake.py:1
xbee.tests.test_fake.TestFakeReadDevice.test_read_multiple_bytes
def test_read_multiple_bytes(self)
Definition: test_fake.py:33
xbee.tests.test_fake.TestFakeReadDevice.test_read_single_byte
def test_read_single_byte(self)
Definition: test_fake.py:24
xbee.tests.test_fake.TestFakeReadDevice.setUp
def setUp(self)
Definition: test_fake.py:18
xbee.tests.test_fake.TestFakeReadDevice.device
device
Definition: test_fake.py:22
xbee.tests.test_fake.TestFakeReadDevice.test_read_too_many
def test_read_too_many(self)
Definition: test_fake.py:40
xbee.tests.Fake.FakeReadDevice
Definition: Fake.py:25
xbee.tests.test_fake.TestFakeReadDevice
Definition: test_fake.py:13


rosserial_xbee
Author(s): Adam Stambler
autogenerated on Wed Mar 2 2022 00:58:25