diff options
Diffstat (limited to 'test/tools.py')
-rwxr-xr-x | test/tools.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/tools.py b/test/tools.py index 221c362..28bf290 100755 --- a/test/tools.py +++ b/test/tools.py @@ -10,6 +10,7 @@ import wsgiref import wsgiref.simple_server import wsgiref.util import wsgiref.validate +import warnings from StringIO import StringIO try: @@ -28,6 +29,10 @@ def tobs(data): ''' Transforms bytes or unicode into a byte stream. ''' return BytesIO(tob(data)) if BytesIO else StringIO(tob(data)) +def warn(message): + warnings.warn(message, stacklevel=2) + + class ServerTestBase(unittest.TestCase): def setUp(self): ''' Create a new Bottle app set it as default_app and register it to urllib2 ''' @@ -67,7 +72,7 @@ class ServerTestBase(unittest.TestCase): response.close() del response return result - + def postmultipart(self, path, fields, files): env = multipart_environ(fields, files) return self.urlopen(path, method='POST', env=env) @@ -97,7 +102,7 @@ class ServerTestBase(unittest.TestCase): err = bottle.request.environ['wsgi.errors'].errors.read() if search not in err: self.fail('The search pattern "%s" is not included in wsgi.error: %s' % (search, err)) - + def multipart_environ(fields, files): boundary = str(uuid.uuid1()) env = {'REQUEST_METHOD':'POST', |