summaryrefslogtreecommitdiff
path: root/testing/framework/TestCommon.py
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2023-05-03 20:41:15 -0700
committerGitHub <noreply@github.com>2023-05-03 20:41:15 -0700
commit4997bbda807ebdbcd11b1282981c3abb81dd8ee1 (patch)
tree6199e98610c76c39efe59a4dc6e91d31e5a13e96 /testing/framework/TestCommon.py
parent4c835c49219361b08f03b71d1f944e2e74f23545 (diff)
parent84859d565216af998f817e05d0696f3423bb7216 (diff)
downloadscons-git-4997bbda807ebdbcd11b1282981c3abb81dd8ee1.tar.gz
Merge branch 'master' into bug/msys-python
Diffstat (limited to 'testing/framework/TestCommon.py')
-rw-r--r--testing/framework/TestCommon.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py
index 91d5332cd..b0879a6f9 100644
--- a/testing/framework/TestCommon.py
+++ b/testing/framework/TestCommon.py
@@ -211,7 +211,7 @@ def separate_files(flist):
missing.append(f)
return existing, missing
-def contains(seq, subseq, find):
+def contains(seq, subseq, find) -> bool:
# Returns True or False.
if find is None:
return subseq in seq
@@ -234,14 +234,14 @@ def find_index(seq, subseq, find):
if os.name == 'posix':
- def _failed(self, status = 0):
+ def _failed(self, status: int = 0):
if self.status is None or status is None:
return None
return _status(self) != status
def _status(self):
return self.status
elif os.name == 'nt':
- def _failed(self, status = 0):
+ def _failed(self, status: int = 0):
return not (self.status is None or status is None) and \
self.status != status
def _status(self):
@@ -256,7 +256,7 @@ class TestCommon(TestCmd):
#
# $test->copy('src_file', 'dst_file');
- def __init__(self, **kw):
+ def __init__(self, **kw) -> None:
"""Initialize a new TestCommon instance. This involves just
calling the base class initialization, and then changing directory
to the workdir.
@@ -281,7 +281,7 @@ class TestCommon(TestCmd):
return arguments
- def must_be_writable(self, *files):
+ def must_be_writable(self, *files) -> None:
"""Ensures that the specified file(s) exist and are writable.
An individual file can be specified as a list of directory names,
in which case the pathname will be constructed by concatenating
@@ -297,7 +297,7 @@ class TestCommon(TestCmd):
print("Unwritable files: `%s'" % "', `".join(unwritable))
self.fail_test(missing + unwritable)
- def must_contain(self, file, required, mode='rb', find=None):
+ def must_contain(self, file, required, mode: str='rb', find=None) -> None:
"""Ensures specified file contains the required text.
Args:
@@ -326,7 +326,7 @@ class TestCommon(TestCmd):
print(file_contents)
self.fail_test()
- def must_contain_all(self, output, input, title=None, find=None):
+ def must_contain_all(self, output, input, title=None, find=None) -> None:
"""Ensures that the specified output string (first argument)
contains all of the specified input as a block (second argument).
@@ -349,7 +349,7 @@ class TestCommon(TestCmd):
print(output)
self.fail_test()
- def must_contain_all_lines(self, output, lines, title=None, find=None):
+ def must_contain_all_lines(self, output, lines, title=None, find=None) -> None:
"""Ensures that the specified output string (first argument)
contains all of the specified lines (second argument).
@@ -374,7 +374,7 @@ class TestCommon(TestCmd):
sys.stdout.write(output)
self.fail_test()
- def must_contain_single_instance_of(self, output, lines, title=None):
+ def must_contain_single_instance_of(self, output, lines, title=None) -> None:
"""Ensures that the specified output string (first argument)
contains one instance of the specified lines (second argument).
@@ -401,7 +401,7 @@ class TestCommon(TestCmd):
sys.stdout.write(output)
self.fail_test()
- def must_contain_any_line(self, output, lines, title=None, find=None):
+ def must_contain_any_line(self, output, lines, title=None, find=None) -> None:
"""Ensures that the specified output string (first argument)
contains at least one of the specified lines (second argument).
@@ -425,7 +425,7 @@ class TestCommon(TestCmd):
sys.stdout.write(output)
self.fail_test()
- def must_contain_exactly_lines(self, output, expect, title=None, find=None):
+ def must_contain_exactly_lines(self, output, expect, title=None, find=None) -> None:
"""Ensures that the specified output string (first argument)
contains all of the lines in the expected string (second argument)
with none left over.
@@ -477,7 +477,7 @@ class TestCommon(TestCmd):
# Deprecated; retain for backwards compatibility.
return self.must_contain_all_lines(output, lines, title, find)
- def must_exist(self, *files):
+ def must_exist(self, *files) -> None:
"""Ensures that the specified file(s) must exist. An individual
file be specified as a list of directory names, in which case the
pathname will be constructed by concatenating them. Exits FAILED
@@ -489,7 +489,7 @@ class TestCommon(TestCmd):
print("Missing files: `%s'" % "', `".join(missing))
self.fail_test(missing)
- def must_exist_one_of(self, files):
+ def must_exist_one_of(self, files) -> None:
"""Ensures that at least one of the specified file(s) exists.
The filenames can be given as a list, where each entry may be
a single path string, or a tuple of folder names and the final
@@ -509,7 +509,7 @@ class TestCommon(TestCmd):
print("Missing one of: `%s'" % "', `".join(missing))
self.fail_test(missing)
- def must_match(self, file, expect, mode = 'rb', match=None, message=None, newline=None):
+ def must_match(self, file, expect, mode: str = 'rb', match=None, message=None, newline=None):
"""Matches the contents of the specified file (first argument)
against the expected contents (second argument). The expected
contents are a list of lines or a string which will be split
@@ -527,7 +527,7 @@ class TestCommon(TestCmd):
self.diff(expect, file_contents, 'contents ')
raise
- def must_match_file(self, file, golden_file, mode='rb', match=None, message=None, newline=None):
+ def must_match_file(self, file, golden_file, mode: str='rb', match=None, message=None, newline=None):
"""Matches the contents of the specified file (first argument)
against the expected contents (second argument). The expected
contents are a list of lines or a string which will be split
@@ -548,7 +548,7 @@ class TestCommon(TestCmd):
self.diff(golden_file_contents, file_contents, 'contents ')
raise
- def must_not_contain(self, file, banned, mode = 'rb', find = None):
+ def must_not_contain(self, file, banned, mode: str = 'rb', find = None) -> None:
"""Ensures that the specified file doesn't contain the banned text.
"""
file_contents = self.read(file, mode)
@@ -561,7 +561,7 @@ class TestCommon(TestCmd):
print(file_contents)
self.fail_test()
- def must_not_contain_any_line(self, output, lines, title=None, find=None):
+ def must_not_contain_any_line(self, output, lines, title=None, find=None) -> None:
"""Ensures that the specified output string (first argument)
does not contain any of the specified lines (second argument).
@@ -590,7 +590,7 @@ class TestCommon(TestCmd):
def must_not_contain_lines(self, lines, output, title=None, find=None):
return self.must_not_contain_any_line(output, lines, title, find)
- def must_not_exist(self, *files):
+ def must_not_exist(self, *files) -> None:
"""Ensures that the specified file(s) must not exist.
An individual file be specified as a list of directory names, in
which case the pathname will be constructed by concatenating them.
@@ -602,7 +602,7 @@ class TestCommon(TestCmd):
print("Unexpected files exist: `%s'" % "', `".join(existing))
self.fail_test(existing)
- def must_not_exist_any_of(self, files):
+ def must_not_exist_any_of(self, files) -> None:
"""Ensures that none of the specified file(s) exists.
The filenames can be given as a list, where each entry may be
a single path string, or a tuple of folder names and the final
@@ -622,7 +622,7 @@ class TestCommon(TestCmd):
print("Unexpected files exist: `%s'" % "', `".join(existing))
self.fail_test(existing)
- def must_not_be_empty(self, file):
+ def must_not_be_empty(self, file) -> None:
"""Ensures that the specified file exists, and that it is not empty.
Exits FAILED if the file doesn't exist or is empty.
"""
@@ -639,7 +639,7 @@ class TestCommon(TestCmd):
print(f"File is empty: `{file}'")
self.fail_test(file)
- def must_not_be_writable(self, *files):
+ def must_not_be_writable(self, *files) -> None:
"""Ensures that the specified file(s) exist and are not writable.
An individual file can be specified as a list of directory names,
in which case the pathname will be constructed by concatenating
@@ -656,7 +656,7 @@ class TestCommon(TestCmd):
self.fail_test(missing + writable)
def _complete(self, actual_stdout, expected_stdout,
- actual_stderr, expected_stderr, status, match):
+ actual_stderr, expected_stderr, status, match) -> None:
"""
Post-processes running a subcommand, checking for failure
status and displaying output appropriately.
@@ -716,7 +716,7 @@ class TestCommon(TestCmd):
sys.stderr.write(f'Exception trying to execute: {cmd_args}\n')
raise e
- def finish(self, popen, stdout = None, stderr = '', status = 0, **kw):
+ def finish(self, popen, stdout = None, stderr: str = '', status: int = 0, **kw) -> None:
"""
Finishes and waits for the process being run under control of
the specified popen argument. Additional arguments are similar
@@ -740,7 +740,7 @@ class TestCommon(TestCmd):
self.stderr(), stderr, status, match)
def run(self, options = None, arguments = None,
- stdout = None, stderr = '', status = 0, **kw):
+ stdout = None, stderr: str = '', status: int = 0, **kw) -> None:
"""Runs the program under test, checking that the test succeeded.
The parameters are the same as the base TestCmd.run() method,
@@ -775,7 +775,7 @@ class TestCommon(TestCmd):
self._complete(self.stdout(), stdout,
self.stderr(), stderr, status, match)
- def skip_test(self, message="Skipping test.\n", from_fw=False):
+ def skip_test(self, message: str="Skipping test.\n", from_fw: bool=False) -> None:
"""Skips a test.
Proper test-skipping behavior is dependent on the external
@@ -818,7 +818,7 @@ class TestCommon(TestCmd):
self.pass_test()
@staticmethod
- def detailed_diff(value, expect):
+ def detailed_diff(value, expect) -> str:
v_split = value.split('\n')
e_split = expect.split('\n')
if len(v_split) != len(e_split):