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)


rosserial_xbee
Author(s): Adam Stambler
autogenerated on Mon Jun 10 2019 14:53:52