summaryrefslogtreecommitdiffstats
path: root/QMTest/TestCommon.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2010-01-12 07:14:49 (GMT)
committerSteven Knight <knight@baldmt.com>2010-01-12 07:14:49 (GMT)
commit712485a2fef16ee9b1850c7ed634e3d402706286 (patch)
tree6371be6f016d68970a236d052136ed8092404c0d /QMTest/TestCommon.py
parenta62d7407d4db87ca70a74b659cd947fedbd84d16 (diff)
downloadSCons-712485a2fef16ee9b1850c7ed634e3d402706286.zip
SCons-712485a2fef16ee9b1850c7ed634e3d402706286.tar.gz
SCons-712485a2fef16ee9b1850c7ed634e3d402706286.tar.bz2
Update Test{Cmd,Common}.py from upstream, with a new
TestCommon.must_not_contain() method, new-style classes (inherit from object), and a fix for a Windows race by only opening up a pipe to stdin if we have something to write to it.
Diffstat (limited to 'QMTest/TestCommon.py')
-rw-r--r--QMTest/TestCommon.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 5356fac..4aa7185 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -46,6 +46,8 @@ provided by the TestCommon class:
test.must_not_be_writable('file1', ['file2', ...])
+ test.must_not_contain('file', 'banned text\n')
+
test.must_not_contain_any_line(output, lines, ['title', find])
test.must_not_exist('file1', ['file2', ...])
@@ -70,7 +72,7 @@ The TestCommon module also provides the following variables
"""
-# Copyright 2000, 2001, 2002, 2003, 2004 Steven Knight
+# Copyright 2000-2010 Steven Knight
# This module is free software, and you may redistribute it and/or modify
# it under the same terms as Python itself, so long as this copyright message
# and disclaimer are retained in their original form.
@@ -87,8 +89,8 @@ The TestCommon module also provides the following variables
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.36.D001 2009/07/24 08:45:26 knight"
-__version__ = "0.36"
+__revision__ = "TestCommon.py 0.37.D001 2010/01/11 16:55:50 knight"
+__version__ = "0.37"
import copy
import os
@@ -333,6 +335,19 @@ class TestCommon(TestCmd):
self.diff(expect, file_contents, 'contents ')
raise
+ def must_not_contain(self, file, banned, mode = 'rb'):
+ """Ensures that the specified file doesn't contain the banned text.
+ """
+ file_contents = self.read(file, mode)
+ contains = (string.find(file_contents, banned) != -1)
+ if contains:
+ print "File `%s' contains banned string." % file
+ print self.banner('Banned string ')
+ print banned
+ print self.banner('%s contents ' % file)
+ print file_contents
+ self.fail_test(contains)
+
def must_not_contain_any_line(self, output, lines, title=None, find=None):
"""Ensures that the specified output string (first argument)
does not contain any of the specified lines (second argument).