summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2015-08-06 17:52:51 +0200
committerChris Liechti <cliechti@gmx.net>2015-08-06 17:52:51 +0200
commitd73344dcbe7e794b61674998d6215e61ffbceb44 (patch)
treee9f442eb1444d743982642147c6585584b3c231b /test
parent33f0ec53d72fb133c8b791fdf892cd975ef8d77f (diff)
downloadpyserial-git-d73344dcbe7e794b61674998d6215e61ffbceb44.tar.gz
test: improve test reliability
Diffstat (limited to 'test')
-rw-r--r--test/run_all_tests.py3
-rw-r--r--test/test.py15
-rw-r--r--test/test_rs485.py2
3 files changed, 13 insertions, 7 deletions
diff --git a/test/run_all_tests.py b/test/run_all_tests.py
index 0fbd3b8..3789fe5 100644
--- a/test/run_all_tests.py
+++ b/test/run_all_tests.py
@@ -25,7 +25,7 @@ if len(sys.argv) > 1:
mainsuite = unittest.TestSuite()
for modulename in [
os.path.splitext(x)[0]
- for x in os.listdir(os.path.dirname(__file__))
+ for x in os.listdir(os.path.dirname(__file__) or '.')
if x != __file__ and x.startswith("test") and x.endswith(".py")
]:
try:
@@ -41,6 +41,7 @@ for modulename in [
verbosity = 1
if '-v' in sys.argv[1:]:
verbosity = 2
+ print('-'*78)
# run the collected tests
testRunner = unittest.TextTestRunner(verbosity=verbosity)
diff --git a/test/test.py b/test/test.py
index 0cd46b4..b2ec7c6 100644
--- a/test/test.py
+++ b/test/test.py
@@ -2,12 +2,12 @@
# Python Serial Port Extension for Win32, Linux, BSD, Jython
# see __init__.py
#
-# (C) 2001-2008 Chris Liechti <cliechti@gmx.net>
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
# this is distributed under a free software license, see license.txt
"""\
Some tests for the serial module.
-Part of pyserial (http://pyserial.sf.net) (C)2001-2009 cliechti@gmx.net
+Part of pyserial (http://pyserial.sf.net) (C)2001-2015 cliechti@gmx.net
Intended to be run on different platforms, to ensure portability of
the code.
@@ -203,15 +203,20 @@ class Test_MoreTimeouts(unittest.TestCase):
def tearDown(self):
#~ self.s.write(serial.XON)
- self.s.flushInput()
+ self.s.close()
+ # reopen... some faulty USB-serial adapter make next test fail otherwise...
+ self.s.timeout = 1
+ self.s.xonxoff = False
+ self.s.open()
+ self.s.read(10)
self.s.close()
def test_WriteTimeout(self):
"""Test write() timeout."""
# use xonxoff setting and the loop-back adapter to switch traffic on hold
self.s.port = PORT
- self.s.writeTimeout = 1
- self.s.xonxoff = 1
+ self.s.writeTimeout = True
+ self.s.xonxoff = True
self.s.open()
self.s.write(serial.XOFF)
time.sleep(0.5) # some systems need a little delay so that they can react on XOFF
diff --git a/test/test_rs485.py b/test/test_rs485.py
index df77e8c..813d6c8 100644
--- a/test/test_rs485.py
+++ b/test/test_rs485.py
@@ -44,7 +44,7 @@ class Test_RS485_class(unittest.TestCase):
"""Test RS485 class"""
def setUp(self):
- self.s = serial.rs485.RS485(PORT, timeout=3)
+ self.s = serial.rs485.RS485(PORT, timeout=1)
def tearDown(self):
self.s.close()