summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2023-08-04 14:37:28 (GMT)
committerMats Wichmann <mats@linux.com>2023-08-04 14:42:12 (GMT)
commitf3d1936c34333b8b535269a007a5598e93029bc0 (patch)
treed57e134d5dca344c8da28b7c62290f2c4ac6127e /testing
parente141cd3288ece58340a1a9e5d99a8c4f810366a9 (diff)
downloadSCons-f3d1936c34333b8b535269a007a5598e93029bc0.zip
SCons-f3d1936c34333b8b535269a007a5598e93029bc0.tar.gz
SCons-f3d1936c34333b8b535269a007a5598e93029bc0.tar.bz2
"Modernize" to Python 3.6 via tool
$ pyupgrade --py36-plus $(<filelist) Here's mostly what it's done: - No more 'stringliteral'.encode('utf-8'): now b'stringliteral' - No more unicode literals - the default open mode is 'r', leaves out if default - some f-string conversions (if shorter) - catch OSError instead of subclasses - no more mention of "object" - generator expression instead of list comp. when safe - a few tests had a shebang but actually began with blank line - remove coding: utf-8 comment, per pep 3120 this is the default now Manually - if a file in test/ was modified, then did the copyright header conversion. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'testing')
-rw-r--r--testing/framework/TestCmd.py6
-rw-r--r--testing/framework/TestSCons.py2
-rw-r--r--testing/framework/TestUnit/__init__.py1
3 files changed, 4 insertions, 5 deletions
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py
index 5cdeea0..723b9ec 100644
--- a/testing/framework/TestCmd.py
+++ b/testing/framework/TestCmd.py
@@ -605,7 +605,7 @@ def match_re(lines=None, res=None):
print(f"match_re: expected {len(res)} lines, found {len(lines)}")
return None
for i, (line, regex) in enumerate(zip(lines, res)):
- s = r"^{}$".format(regex)
+ s = fr"^{regex}$"
try:
expr = re.compile(s)
except re.error as e:
@@ -635,7 +635,7 @@ def match_re_dotall(lines=None, res=None):
lines = "\n".join(lines)
if not isinstance(res, str):
res = "\n".join(res)
- s = r"^{}$".format(res)
+ s = fr"^{res}$"
try:
expr = re.compile(s, re.DOTALL)
except re.error as e:
@@ -714,7 +714,7 @@ def diff_re(a, b, fromfile: str='', tofile: str='',
elif diff > 0:
b = b + [''] * diff
for i, (aline, bline) in enumerate(zip(a, b)):
- s = r"^{}$".format(aline)
+ s = fr"^{aline}$"
try:
expr = re.compile(s)
except re.error as e:
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py
index 0211283..39a4245 100644
--- a/testing/framework/TestSCons.py
+++ b/testing/framework/TestSCons.py
@@ -1835,7 +1835,7 @@ class TimeSCons(TestSCons):
def uptime(self) -> None:
try:
fp = open('/proc/loadavg')
- except EnvironmentError:
+ except OSError:
pass
else:
avg1, avg5, avg15 = fp.readline().split(" ")[:3]
diff --git a/testing/framework/TestUnit/__init__.py b/testing/framework/TestUnit/__init__.py
index 51cf972..be5007f 100644
--- a/testing/framework/TestUnit/__init__.py
+++ b/testing/framework/TestUnit/__init__.py
@@ -1,4 +1,3 @@
-
__all__ = ['TAPTestRunner', 'TAPTestResult', 'run']
from .taprunner import TAPTestRunner, TAPTestResult