summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/framework/TestCmd.py43
-rw-r--r--testing/framework/TestCmdTests.py20
-rw-r--r--testing/framework/TestCommon.py2
-rw-r--r--testing/framework/TestCommonTests.py7
-rw-r--r--testing/framework/TestSCons.py1
-rw-r--r--testing/framework/TestSCons_time.py1
-rw-r--r--testing/framework/TestSConsign.py1
7 files changed, 34 insertions, 41 deletions
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py
index f29449f..ed8b4b4 100644
--- a/testing/framework/TestCmd.py
+++ b/testing/framework/TestCmd.py
@@ -285,7 +285,6 @@ version.
# PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-from __future__ import division, print_function
__author__ = "Steven Knight <knight at baldmt dot com>"
__revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight"
@@ -492,11 +491,9 @@ def match_caseinsensitive(lines=None, matches=None):
"""
Match function using case-insensitive matching.
- Only a simplistic comparison is done, based on lowercasing the
- strings. This has plenty of holes for unicode data using
- non-English languages.
-
- TODO: casefold() is better than lower() if we don't need Py2 support.
+ Only a simplistic comparison is done, based on casefolding
+ the strings. This may still fail but is the suggestion of
+ the Unicode Standard.
:param lines: data lines
:type lines: str or list[str]
@@ -512,7 +509,7 @@ def match_caseinsensitive(lines=None, matches=None):
if len(lines) != len(matches):
return None
for line, match in zip(lines, matches):
- if line.lower() != match.lower():
+ if line.casefold() != match.casefold():
return None
return 1
@@ -700,7 +697,7 @@ if sys.platform == 'win32':
if is_String(pathext):
pathext = pathext.split(os.pathsep)
for ext in pathext:
- if ext.lower() == file[-len(ext):].lower():
+ if ext.casefold() == file[-len(ext):].casefold():
pathext = ['']
break
for dir in path:
@@ -1504,13 +1501,13 @@ class TestCmd(object):
@staticmethod
def fix_binary_stream(stream):
"""
- Handle stdout/stderr from popen when we specify universal_newlines = False.
+ Handle stdout/stderr from popen when we specify not universal_newlines
- This will read from the pipes in binary mode, not decode the output,
- and not convert line endings to \n.
+ This will read from the pipes in binary mode, will not decode the
+ output, and will not convert line endings to \n.
We do this because in py3 (3.5) with universal_newlines=True, it will
choose the default system locale to decode the output, and this breaks unicode
- output. Specifically breaking test/option--tree.py which outputs a unicode char.
+ output. Specifically test/option--tree.py which outputs a unicode char.
py 3.6 allows us to pass an encoding param to popen thus not requiring the decode
nor end of line handling, because we propagate universal_newlines as specified.
@@ -1968,13 +1965,20 @@ class TestCmd(object):
do_chmod(top)
def write(self, file, content, mode='wb'):
- """Writes the specified content text (second argument) to the
- specified file name (first argument). The file name may be
- a list, in which case the elements are concatenated with the
- os.path.join() method. The file is created under the temporary
- working directory. Any subdirectories in the path must already
- exist. The I/O mode for the file may be specified; it must
- begin with a 'w'. The default is 'wb' (binary write).
+ """Write data to file
+
+ The file is created under the temporary working directory.
+ Any subdirectories in the path must already exist. The
+ write is converted to the required type rather than failing
+ if there is a str/bytes mistmatch.
+
+ :param file: name of file to write to. If a list, treated
+ as components of a path and concatenated into a path.
+ :type file: str or list(str)
+ :param content: data to write.
+ :type content: str or bytes
+ :param mode: file mode, default is binary.
+ :type mode: str
"""
file = self.canonicalize(file)
if mode[0] != 'w':
@@ -1983,7 +1987,6 @@ class TestCmd(object):
try:
f.write(content)
except TypeError as e:
- # python 3 default strings are not bytes, but unicode
f.write(bytes(content, 'utf-8'))
# Local Variables:
diff --git a/testing/framework/TestCmdTests.py b/testing/framework/TestCmdTests.py
index 48eba1e..e8c2744 100644
--- a/testing/framework/TestCmdTests.py
+++ b/testing/framework/TestCmdTests.py
@@ -254,7 +254,7 @@ class cleanup_TestCase(TestCmdTestCase):
def test_atexit(self):
"""Test cleanup() when atexit is used"""
- self.popen_python("""from __future__ import print_function
+ self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
import atexit
@@ -269,7 +269,7 @@ sys.exit(0)
@unittest.skipIf(TestCmd.IS_PY3, "No sys.exitfunc in Python 3")
def test_exitfunc(self):
"""Test cleanup() when sys.exitfunc is set"""
- self.popen_python("""from __future__ import print_function
+ self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
def my_exitfunc():
@@ -609,7 +609,7 @@ sys.exit(0)
def test_diff_stderr_not_affecting_diff_stdout(self):
"""Test diff_stderr() not affecting diff_stdout() behavior"""
- self.popen_python(r"""from __future__ import print_function
+ self.popen_python(r"""
import sys
sys.path = ['%s'] + sys.path
import TestCmd
@@ -716,7 +716,7 @@ sys.exit(0)
def test_diff_stdout_not_affecting_diff_stderr(self):
"""Test diff_stdout() not affecting diff_stderr() behavior"""
- self.popen_python(r"""from __future__ import print_function
+ self.popen_python(r"""
import sys
sys.path = ['%s'] + sys.path
import TestCmd
@@ -2089,7 +2089,7 @@ sys.exit(0)
def test_set_diff_function_stdout(self):
"""Test set_diff_function(): stdout"""
- self.popen_python("""from __future__ import print_function
+ self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
import TestCmd
@@ -2118,7 +2118,7 @@ diff_stdout:
def test_set_diff_function_stderr(self):
"""Test set_diff_function(): stderr """
- self.popen_python("""from __future__ import print_function
+ self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
import TestCmd
@@ -2693,7 +2693,7 @@ class stdin_TestCase(TestCmdTestCase):
def test_stdin(self):
"""Test stdin()"""
run_env = TestCmd.TestCmd(workdir = '')
- run_env.write('run', """from __future__ import print_function
+ run_env.write('run', """\
import fileinput
for line in fileinput.input():
print('Y'.join(line[:-1].split('X')))
@@ -3332,15 +3332,13 @@ class variables_TestCase(TestCmdTestCase):
'TestCmd',
]
- script = "from __future__ import print_function\n" + \
- "import TestCmd\n" + \
+ script = "import TestCmd\n" + \
'\n'.join([ "print(TestCmd.%s\n)" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
assert stderr == "", stderr
- script = "from __future__ import print_function\n" + \
- "from TestCmd import *\n" + \
+ script = "from TestCmd import *\n" + \
'\n'.join([ "print(%s)" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py
index 8e6cc8e..1bd9f6b 100644
--- a/testing/framework/TestCommon.py
+++ b/testing/framework/TestCommon.py
@@ -93,8 +93,6 @@ The TestCommon module also provides the following variables
# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-from __future__ import print_function
-
__author__ = "Steven Knight <knight at baldmt dot com>"
__revision__ = "TestCommon.py 1.3.D001 2010/06/03 12:58:27 knight"
__version__ = "1.3"
diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py
index 6377737..01e9fe1 100644
--- a/testing/framework/TestCommonTests.py
+++ b/testing/framework/TestCommonTests.py
@@ -167,7 +167,6 @@ class __init__TestCase(TestCommonTestCase):
os.chdir(run_env.workdir)
script = lstrip("""\
- from __future__ import print_function
from TestCommon import TestCommon
tc = TestCommon(workdir='')
import os
@@ -2340,15 +2339,13 @@ class variables_TestCase(TestCommonTestCase):
'dll_suffix',
]
- script = "from __future__ import print_function\n" + \
- "import TestCommon\n" + \
+ script = "import TestCommon\n" + \
'\n'.join([ "print(TestCommon.%s)\n" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
assert stderr == "", stderr
- script = "from __future__ import print_function\n" + \
- "from TestCommon import *\n" + \
+ script = "from TestCommon import *\n" + \
'\n'.join([ "print(%s)" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py
index 2f20950..8800c1b 100644
--- a/testing/framework/TestSCons.py
+++ b/testing/framework/TestSCons.py
@@ -13,7 +13,6 @@ attributes defined in this subclass.
"""
# __COPYRIGHT__
-from __future__ import division, print_function
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
diff --git a/testing/framework/TestSCons_time.py b/testing/framework/TestSCons_time.py
index f27e0e3..6f46e26 100644
--- a/testing/framework/TestSCons_time.py
+++ b/testing/framework/TestSCons_time.py
@@ -27,7 +27,6 @@ from TestSCons import search_re, search_re_in_list
__all__.extend(['TestSCons_time',])
SConstruct = """\
-from __future__ import print_function
import os
print("SConstruct file directory:", os.getcwd())
"""
diff --git a/testing/framework/TestSConsign.py b/testing/framework/TestSConsign.py
index a48b648..665059c 100644
--- a/testing/framework/TestSConsign.py
+++ b/testing/framework/TestSConsign.py
@@ -1,5 +1,4 @@
# __COPYRIGHT__
-from __future__ import print_function
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"