summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-08-30 13:59:29 (GMT)
committerMats Wichmann <mats@linux.com>2019-08-30 14:04:23 (GMT)
commit49212c0d8dc8db6657735036028948bf3ab9ede0 (patch)
tree08f0ea34bbc36d51a8234a72ea5fe65d3f44c68e /test
parent84843df640e34f83ebea25be851204f400a0d9ec (diff)
downloadSCons-49212c0d8dc8db6657735036028948bf3ab9ede0.zip
SCons-49212c0d8dc8db6657735036028948bf3ab9ede0.tar.gz
SCons-49212c0d8dc8db6657735036028948bf3ab9ede0.tar.bz2
Use "in" in preference to string find method
In places where only the found/not found status is needed, use the membership operator (in) for checks instead - makes for easier reading and is considered faster for shorter strings. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r--test/Configure/option--config.py2
-rw-r--r--test/Java/RMIC.py14
-rw-r--r--test/QT/installed.py16
-rw-r--r--test/Repository/RMIC.py6
-rw-r--r--test/Win32/mingw.py16
5 files changed, 27 insertions, 27 deletions
diff --git a/test/Configure/option--config.py b/test/Configure/option--config.py
index ad4f144..838409d 100644
--- a/test/Configure/option--config.py
+++ b/test/Configure/option--config.py
@@ -144,7 +144,7 @@ test.must_not_contain(test.workpath('config.log'), "TypeError: 'NoneType' object
# This fixes an issue where --config=force overwrites the Environments decider and is not reset when
# the configure context is done.
# https://github.com/SCons/scons/issues/3303
-test.fail_test(test.stdout().find('test_main.o') != -1)
+test.fail_test('test_main.o' in test.stdout())
test.pass_test()
diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py
index c8848e9..67135b9 100644
--- a/test/Java/RMIC.py
+++ b/test/Java/RMIC.py
@@ -95,7 +95,7 @@ line 3
where_javac, java_version = test.java_where_javac()
where_rmic = test.java_where_rmic()
-# Try to get the major/minor Java version
+# Try to get the major/minor Java version
curver = (1, 0)
if java_version.count('.') == 1:
# Check Java version
@@ -138,7 +138,7 @@ bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar')
# XXX This is kind of a Python brute-force way to do what Ant
# does with its "excludes" attribute. We should probably find
# a similar friendlier way to do this.
-bar_classes = [c for c in bar_classes if str(c).find('Hello') == -1]
+bar_classes = [c for c in bar_classes if 'Hello' not in str(c)]
bar.RMIC(target = Dir('outdir2'), source = bar_classes)
""" % locals() )
@@ -149,7 +149,7 @@ bar.RMIC(target = Dir('outdir2'), source = bar_classes)
['com', 'sub', 'bar'],
'src3a',
'src3b')
-
+
test.write(['com', 'sub', 'foo', 'Hello.java'], """\
package com.sub.foo;
@@ -329,16 +329,16 @@ public class Example4 extends UnicastRemoteObject implements Hello {
""")
test.run(arguments = '.')
-
+
test.must_match('wrapper.out',
"wrapper_with_args.py rmic -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n",
mode='r')
-
+
test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class'))
test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Stub.class'))
test.must_exist(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example3_Stub.class'))
test.must_exist(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example4_Stub.class'))
-
+
# We used to check for _Skel.class files as well, but they're not
# generated by default starting with Java 1.5, and they apparently
# haven't been needed for a while. Don't bother looking, even if we're
@@ -348,7 +348,7 @@ public class Example4 extends UnicastRemoteObject implements Hello {
#test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Skel.class'))
#test.must_exist(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example3_Skel.class'))
#test.must_exist(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example4_Skel.class'))
-
+
test.up_to_date(arguments = '.')
test.pass_test()
diff --git a/test/QT/installed.py b/test/QT/installed.py
index 2661377..c3ba168 100644
--- a/test/QT/installed.py
+++ b/test/QT/installed.py
@@ -42,7 +42,7 @@ if not os.environ.get('QTDIR', None):
test.Qt_dummy_installation()
QTDIR=os.environ['QTDIR']
-
+
test.write('SConstruct', """\
import os
@@ -109,17 +109,17 @@ class MyClass2 : public QObject {
};
void mocFromH();
""")
-
+
test.write('mocFromH.cpp', """\
#include "mocFromH.h"
-
+
MyClass2::MyClass2() : QObject() {}
void MyClass2::myslot() {}
void mocFromH() {
MyClass2 myclass;
}
""")
-
+
test.write('anUiFile.ui', """\
<!DOCTYPE UI><UI>
<class>MyWidget</class>
@@ -158,7 +158,7 @@ test.write('main.cpp', r"""
#include "mocFromH.h"
#include "anUiFile.h"
#include <stdio.h>
-
+
int main(int argc, char **argv) {
QApplication app(argc, argv);
mocFromCpp();
@@ -190,7 +190,7 @@ if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status:
# an indication that it built correctly) but don't fail the test.
expect = 'cannot connect to X server'
test.fail_test(test.stdout())
- test.fail_test(test.stderr().find(expect) == -1)
+ test.fail_test(expect not in test.stderr())
if test.status != 1 and (test.status>>8) != 1:
sys.stdout.write('test_realqt returned status %s\n' % test.status)
test.fail_test()
@@ -205,8 +205,8 @@ test.run(stderr=None, arguments="-c bld/test_realqt" + TestSCons._exe)
expect1 = "scons: warning: Could not detect qt, using empty QTDIR"
expect2 = "scons: warning: Could not detect qt, using moc executable as a hint"
-test.fail_test(test.stderr().find(expect1) == -1 and
- test.stderr().find(expect2) == -1)
+test.fail_test(expect1 not in test.stderr() and
+ expect2 not in test.stderr())
test.pass_test()
diff --git a/test/Repository/RMIC.py b/test/Repository/RMIC.py
index aa4a57e..7c37dd9 100644
--- a/test/Repository/RMIC.py
+++ b/test/Repository/RMIC.py
@@ -37,7 +37,7 @@ test = TestSCons.TestSCons()
where_javac, java_version = test.java_where_javac()
-# Try to get the major/minor Java version
+# Try to get the major/minor Java version
curver = (1, 0)
if java_version.count('.') == 1:
# Check Java version
@@ -97,7 +97,7 @@ env = Environment(tools = ['javac', 'rmic'],
RMIC = r'"%s"')
classes = env.Java(target = 'classes', source = 'src')
# Brute-force removal of the "Hello" class.
-classes = [c for c in classes if str(c).find('Hello') == -1]
+classes = [c for c in classes if 'Hello' not in str(c)]
env.RMIC(target = 'outdir', source = classes)
""" % (javac, rmic))
@@ -365,7 +365,7 @@ env = Environment(tools = ['javac', 'rmic'],
RMIC = r'"%s"')
classes = env.Java(target = 'classes', source = 'src')
# Brute-force removal of the "Hello" class.
-classes = [c for c in classes if str(c).find('Hello') == -1]
+classes = [c for c in classes if 'Hello' not in str(c)]
rmi_classes = env.RMIC(target = 'outdir', source = classes)
Local(rmi_classes)
""" % (javac, rmic))
diff --git a/test/Win32/mingw.py b/test/Win32/mingw.py
index 80067bc..ca31f6b 100644
--- a/test/Win32/mingw.py
+++ b/test/Win32/mingw.py
@@ -52,7 +52,7 @@ sys.exit(0)
""")
test.run()
-if test.stdout().find('mingw exists') == -1:
+if 'mingw exists' not in test.stdout():
test.skip_test("No MinGW on this system, skipping test.\n")
test.subdir('header')
@@ -76,8 +76,8 @@ void shared_func(void);
void static_func(void);
extern "C" void cshared_func(void);
-int main(void)
-{
+int main(void)
+{
printf("%s\\n", "test.cpp");
shared_func();
static_func();
@@ -95,7 +95,7 @@ test.write('resource.rc', '''
#include "resource.h"
#include <resource2.h>
-STRINGTABLE DISCARDABLE
+STRINGTABLE DISCARDABLE
BEGIN
IDS_TEST RESOURCE_RC
END
@@ -148,8 +148,8 @@ test.write('header/resource2.h', '''
# that comes out of stderr:
test.run(arguments='test.exe', stderr='.*')
# ensure the source def for cshared.def got used, and there wasn't a target def for chshared.dll:
-test.fail_test(test.stdout().find('cshared.def') == -1)
-test.fail_test(test.stdout().find('-Wl,--output-def,cshared.def') != -1)
+test.fail_test('cshared.def' not in test.stdout())
+test.fail_test('-Wl,--output-def,cshared.def' in test.stdout())
# ensure the target def got generated for the shared.dll:
test.fail_test(not os.path.exists(test.workpath('cshared.def')))
test.fail_test(os.path.exists(test.workpath('shared.def')))
@@ -176,8 +176,8 @@ test.write('test.cpp', '''
void shared_func(void);
-int main(void)
-{
+int main(void)
+{
printf("%s\\n", "test.cpp2");
shared_func();
return 0;