Improved Fake Serial device used by unit tests#25
Improved Fake Serial device used by unit tests#25hansmosh merged 4 commits intoniolabs:masterfrom jamesleesaunders:fake-serial
Conversation
|
I was also considering whether it would also be appropriate to rename the file 'Fake.py' to 'fakeSerial.py' (along with all its refs) to make it more obvious what it is. If you think this a good idea I can do this in a subsequent PR. |
* Merged FakeDevice and FakeReadDevice into one. * Added defaults for port, baudrate, timeout, xonxoff etc. * Added readline() function. * Added set_read_data() to set the data to be used by read() and readline(). * Added get_data_written() returns data passed to write(). * Added getSettingsDict() Get a dictionary with port settings. * Added further docstring comments.
* Replaced the previous FakeDevice and FakeReadDevice with the new fake Serial class. * Use of get_data_written(). * Modify BadReadDevice accordingly. * Adding default second argument 'length' to BadReadDevice(). * Removed test_read_too_many() test as no longer required.
|
Hi @hansmosh Please consider this PR for inclusion upstream. This PR improves (and simplifies some of the python-xbee tests. |
|
Hi @pmalmsten This PR may be of interest to you also? |
|
Chris? |
|
@jamesleesaunders: My bad, I wasn't getting notifications from GitHub about this. I'll take a look this week. |
|
Did you get a chance to review? |
hansmosh
left a comment
There was a problem hiding this comment.
Just one simple little fix and then I'll go ahead and merge this in.
I appreciate you taking the time to clean this up a little. I definitely like the merging of those two test devices into one.
I actually think that if we were to keep going with this exercise, it would make sense to get rid of that fake device entirely and use a MagicMock.
| self.set_read_data(data) | ||
|
|
||
| def inWaiting(self): | ||
| def in_waiting(self): |
There was a problem hiding this comment.
This is never called. I don't think it should have been changed from inWaiting. The test passes either way so I'm not sure why this is even here. I say either delete it or change it back.
|
@hansmosh Thanks for looking at this PR, I am glad you like the merging of the fake serial devices. I have made the requested changes. The reason for this, was that I did start to replace a couple of the now deprecated pySerial functions with their newer counterparts (https://pythonhosted.org/pyserial/pyserial_api.html?highlight=inwaiting#serial.Serial.inWaiting)...
|
|
@hansmosh Happy New Year! |
This PR proposes a number of improvements to the Fake Serial device which is used by the python-xbee unit tests to simulate a serial device.
The reason for these improvements are to support PR #27 which I am which adds support to base.py to attempt to recover from serial failure or unplug. In order for this to work I needed to embellish the Fake.py test device.