Skip to content

Commit 129a10b

Browse files
committed
Fix test/SCONSFLAGS.py to handle python version deprecation message
1 parent 7590c5d commit 129a10b

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

test/SCONSFLAGS.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
import TestCmd
2929
import TestSCons
3030

31-
test = TestSCons.TestSCons(match = TestCmd.match_re_dotall,ignore_python_version=0)
31+
test = TestSCons.TestSCons(match=TestCmd.match_re_dotall, ignore_python_version=False)
3232

3333
wpath = test.workpath()
3434

3535
test.write('SConstruct', r"""
3636
Help("Help text.\n")
3737
""")
3838

39-
expect = """scons: Reading SConscript files ...
39+
expect_help = """\
40+
scons: Reading SConscript files ...
4041
scons: done reading SConscript files.
4142
Help text.
4243
@@ -45,31 +46,33 @@
4546

4647
os.environ['SCONSFLAGS'] = ''
4748

48-
test.run(arguments = '-h',
49-
stdout = expect,
50-
stderr = TestSCons.deprecated_python_expr)
49+
test.run(arguments='-h',
50+
stdout=expect_help,
51+
stderr=TestSCons.deprecated_python_expr)
5152

5253
os.environ['SCONSFLAGS'] = '-h'
5354

54-
test.run(stdout = expect,
55-
stderr = TestSCons.deprecated_python_expr)
55+
test.run(stdout=expect_help,
56+
stderr=TestSCons.deprecated_python_expr)
5657

57-
# No TestSCons.deprecated_python_expr because the -H option gets
58+
# Don't check for deprecated_python_expr because the -H option gets
5859
# processed before the SConscript files and therefore before we check
5960
# for the deprecation warning.
60-
test.run(arguments = "-H")
61+
os.environ['SCONSFLAGS'] = ''
62+
test.run(arguments="-H")
6163

6264
test.must_not_contain_any_line(test.stdout(), ['Help text.'])
6365
test.must_contain_all_lines(test.stdout(), ['-H, --help-options'])
6466

65-
expect = r"""usage: scons [OPTIONS] [VARIABLES] [TARGETS]
67+
expect_no_opt = TestSCons.deprecated_python_expr + \
68+
r"""usage: scons \[OPTIONS\] \[VARIABLES\] \[TARGETS\]
6669
6770
SCons Error: no such option: -Z
6871
"""
6972

70-
test.run(arguments="-Z", status=2, stderr=expect, match=TestSCons.match_exact)
73+
test.run(arguments="-Z", status=2, stdout=None, stderr=expect_no_opt)
7174

7275
os.environ['SCONSFLAGS'] = '-Z'
73-
test.run(status=2, stderr=expect, match=TestSCons.match_exact)
76+
test.run(status=2, stdout=None, stderr=expect_no_opt)
7477

7578
test.pass_test()

testing/framework/TestSCons.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,17 @@ def deprecated_python_version(version=sys.version_info):
190190

191191

192192
if deprecated_python_version():
193-
msg = r"""
194-
scons: warning: Support for Python older than %s is deprecated (%s detected).
193+
deprecated_python_msg = rf"""
194+
scons: warning: Support for Python older than {python_version_supported_str} is deprecated ({python_version_string()} detected).
195195
If this will cause hardship, contact scons-dev@python.org
196196
"""
197197
deprecated_python_expr = (
198-
re_escape(msg % (python_version_supported_str, python_version_string()))
198+
re_escape(deprecated_python_msg )
199199
+ file_expr
200200
)
201-
del msg
202201
else:
203202
deprecated_python_expr = ""
203+
deprecated_python_msg = ""
204204

205205

206206
def initialize_sconsflags(ignore_python_version):

0 commit comments

Comments
 (0)