Skip to content

Commit

Permalink
Force serial testing when appropriate via tox
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Aug 19, 2019
1 parent 0dfa4b0 commit 5360f0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/twisted/internet/test/test_win32serialport.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@
from twisted.python.runtime import platform
from twisted.internet.test.test_serialport import DoNothing


testing_forced = os.environ.get('TWISTED_FORCE_SERIAL_TESTS', '')
testing_forced = testing_forced.lower() in {'1', 'yes', 'true'}


try:
from twisted.internet import serialport
import serial
except ImportError:
if testing_forced:
raise

serialport = None
serial = None

Expand Down Expand Up @@ -68,11 +76,12 @@ class Win32SerialPortTests(unittest.TestCase):
Minimal testing for Twisted's Win32 serial port support.
"""

if not platform.isWindows():
skip = "This test must run on Windows."
if not testing_forced:
if not platform.isWindows():
skip = "This test must run on Windows."

elif not serialport:
skip = "Windows serial port support is not available."
elif not serialport:
skip = "Windows serial port support is not available."

def setUp(self):
# Re-usable protocol and reactor
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extras =

alldeps-macos: osx_platform

serial: serial

; Documentation needs Twisted install to get the version.
narrativedocs: dev

Expand Down Expand Up @@ -88,6 +90,9 @@ setenv =
; This includes variants of bit depth, unicode width, etc.
wheels: CIBW_BUILD=cp27-* cp35-* cp36-* cp37-*

; If serial or windows extras, force serial testing
{windows,serial}: TWISTED_FORCE_SERIAL_TESTS = 1

commands =
;
; Display information about Python interpreter
Expand Down

0 comments on commit 5360f0e

Please sign in to comment.