summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremerson.prado <emerson.prado@dataprev.gov.br>2019-03-05 13:52:58 -0300
committeremerson.prado <emerson.prado@dataprev.gov.br>2019-03-05 13:55:19 -0300
commitffb1e0a3f37aa8238d50f5443c2f85d83c5f84aa (patch)
treed5de6792c624f90609a09f7b4a3fa3aa476194a1
parent03168dd3cb57cbafebccef0d46e00c6bbd4bb0b9 (diff)
downloadpexpect-ffb1e0a3f37aa8238d50f5443c2f85d83c5f84aa.tar.gz
Add type selection helper function for regex coercing tests
-rwxr-xr-xtests/test_expect.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_expect.py b/tests/test_expect.py
index 2c74744..2232e37 100755
--- a/tests/test_expect.py
+++ b/tests/test_expect.py
@@ -25,11 +25,14 @@ import time
import signal
import sys
import os
+import re
import pexpect
from . import PexpectTestCase
from .utils import no_coverage_env
+PY3 = bool(sys.version_info.major >= 3)
+
# Many of these test cases blindly assume that sequential directory
# listings of the /bin directory will yield the same results.
# This may not be true, but seems adequate for testing now.
@@ -101,6 +104,23 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
p.sendeof ()
p.expect (pexpect.EOF)
+ def _select_types(self, encoding=None):
+ if encoding is None:
+ if PY3:
+ expect_string = 'String'
+ expected_type = bytes
+ else:
+ expect_string = u'String'
+ expected_type = str
+ else:
+ if PY3:
+ expect_string = b'String'
+ expected_type = str
+ else:
+ expect_string = 'String'
+ expected_type = unicode
+ return re.compile(expect_string), expected_type
+
def test_expect_order (self):
'''This tests that patterns are matched in the same order as given in the pattern_list.