Hello community, here is the log from the commit of package python-WebTest for openSUSE:Factory checked in at 2012-02-01 10:00:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-WebTest (Old) and /work/SRC/openSUSE:Factory/.python-WebTest.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-WebTest", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/python-WebTest/python-WebTest.changes 2011-11-28 18:27:32.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-WebTest.new/python-WebTest.changes 2012-02-01 10:00:18.000000000 +0100 @@ -1,0 +2,15 @@ +Tue Jan 31 13:49:10 UTC 2012 - sasc...@suse.de + +- Simplified macro usage +- Run testsuite +- Update to version 1.3.3: + * added post_json, put_json, delete_json + * fix #25 params dictionary of webtest.AppTest.post() does not support unicode values +- Changes from version 1.3.2: + * improve showbrowser. + * print_stderr fail with unicode string on python2 +- Changes from version 1.3.1: + * Added .option() + * Full python3 compat + +------------------------------------------------------------------- Old: ---- WebTest-1.3.tar.gz New: ---- WebTest-1.3.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-WebTest.spec ++++++ --- /var/tmp/diff_new_pack.OoLVE2/_old 2012-02-01 10:00:19.000000000 +0100 +++ /var/tmp/diff_new_pack.OoLVE2/_new 2012-02-01 10:00:19.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-WebTest # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -11,12 +11,11 @@ # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# + # Please submit bugfixes or comments via http://bugs.opensuse.org/ # - Name: python-WebTest -Version: 1.3 +Version: 1.3.3 Release: 0 Url: http://webtest.pythonpaste.org/ Summary: Helper to test WSGI applications @@ -29,15 +28,13 @@ Requires: python-WebOb Requires: python-dtopt Requires: python-nose -%if 0%{?suse_version} -%py_requires -%if 0%{?suse_version} > 1110 -BuildArch: noarch -%endif -%endif Provides: python-webtest = %{version} Obsoletes: python-webtest < %{version} +%if 0%{?suse_version} && 0%{?suse_version} <= 1110 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} +%else +BuildArch: noarch +%endif %description This wraps any WSGI application and makes it easy to send test ++++++ WebTest-1.3.tar.gz -> WebTest-1.3.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/PKG-INFO new/WebTest-1.3.3/PKG-INFO --- old/WebTest-1.3/PKG-INFO 2011-08-28 16:22:13.000000000 +0200 +++ new/WebTest-1.3.3/PKG-INFO 2011-11-21 15:02:55.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: WebTest -Version: 1.3 +Version: 1.3.3 Summary: Helper to test WSGI applications Home-page: http://webtest.pythonpaste.org/ Author: Gael Pasgrimaud @@ -25,3 +25,4 @@ Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/WebTest.egg-info/PKG-INFO new/WebTest-1.3.3/WebTest.egg-info/PKG-INFO --- old/WebTest-1.3/WebTest.egg-info/PKG-INFO 2011-08-28 16:22:12.000000000 +0200 +++ new/WebTest-1.3.3/WebTest.egg-info/PKG-INFO 2011-11-21 15:02:50.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: WebTest -Version: 1.3 +Version: 1.3.3 Summary: Helper to test WSGI applications Home-page: http://webtest.pythonpaste.org/ Author: Gael Pasgrimaud @@ -25,3 +25,4 @@ Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/docs/conf.py new/WebTest-1.3.3/docs/conf.py --- old/WebTest-1.3/docs/conf.py 2011-08-28 16:19:27.000000000 +0200 +++ new/WebTest-1.3.3/docs/conf.py 2011-10-19 12:25:05.000000000 +0200 @@ -39,10 +39,8 @@ # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # -# The short X.Y version. -version = '1.3' # The full version, including alpha/beta/rc tags. -release = '1.3' +version = release = '1.3.2' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -130,3 +128,17 @@ # If false, no module index is generated. #latex_use_modindex = True + +from os import path +pkg_dir = path.abspath(__file__).split('/docs')[0] +setup = path.join(pkg_dir, 'setup.py') +if path.isfile(setup): + for line_ in open(setup): + if line_.startswith("version"): + version = line_.split('=')[-1] + version = version.strip() + version = version.strip("'\"") + release = version + break +del pkg_dir, setup, path + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/docs/index.txt new/WebTest-1.3.3/docs/index.txt --- old/WebTest-1.3/docs/index.txt 2011-08-27 19:09:34.000000000 +0200 +++ new/WebTest-1.3.3/docs/index.txt 2011-10-30 00:51:23.000000000 +0200 @@ -257,7 +257,7 @@ >>> print(form.method) POST >>> # dict of fields - >>> fields = form.fields.items(); fields.sort(); fields + >>> fields.values() #doctest: +SKIP [(u'name', [<Text name="name">]), (u'submit', [<Submit name="submit">])] >>> form['name'] = 'Bob' >>> # When names don't point to a single field: @@ -321,27 +321,25 @@ >>> from webtest import TestRequest >>> from webtest import TestResponse - >>> res = TestResponse(content_type='text/html', body=''' + >>> res = TestResponse(content_type='text/html', body=b''' ... <html><body><div id="content">hey!</div></body>''') >>> res.request = TestRequest.blank('/') - >>> res.html + >>> res.html #doctest: +SKIP <BLANKLINE> <html><body><div id="content">hey!</div></body></html> - >>> res.html.__class__ + >>> res.html.__class__ #doctest: +SKIP <class 'BeautifulSoup.BeautifulSoup'> - >>> res.html.body.div.string - u'hey!' >>> res.lxml <Element html at ...> >>> res.lxml.xpath('//body/div')[0].text 'hey!' >>> res = TestResponse(content_type='application/json', - ... body='{"a":1,"b":2}') + ... body=b'{"a":1,"b":2}') >>> res.request = TestRequest.blank('/') - >>> res.json.values() + >>> list(res.json.values()) [1, 2] >>> res = TestResponse(content_type='application/xml', - ... body='<xml><message>hey!</message></xml>') + ... body=b'<xml><message>hey!</message></xml>') >>> res.request = TestRequest.blank('/') >>> res.xml <Element ...> @@ -355,9 +353,9 @@ 'message' >>> res.lxml[0].text 'hey!' - >>> res.pyquery('message') + >>> res.pyquery('message') #doctest: +SKIP [<message>] - >>> res.pyquery('message').text() + >>> res.pyquery('message').text() #doctest: +SKIP 'hey!' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/docs/news.txt new/WebTest-1.3.3/docs/news.txt --- old/WebTest-1.3/docs/news.txt 2011-08-28 16:20:17.000000000 +0200 +++ new/WebTest-1.3.3/docs/news.txt 2011-10-30 00:38:58.000000000 +0200 @@ -1,9 +1,33 @@ News ==== -1.2.5 +1.3.3 ----- +* added ``post_json``, ``put_json``, ``delete_json`` + +* fix `#25 <https://bitbucket.org/ianb/webtest/issue/25>`_ params dictionary of + webtest.AppTest.post() does not support unicode values + +1.3.2 +----- + +* improve showbrowser. fixed `#23 <https://bitbucket.org/ianb/webtest/issue/23>`_ + +* print_stderr fail with unicode string on python2 + +1.3.1 +----- + +* Added .option() `#20 <https://bitbucket.org/ianb/webtest/issue/20>`_ + +* Fix #21 + +* Full python3 compat + +1.3 +--- + * Moved TestApp to app.py * Added selenium testing framework. See :mod:`~webtest.sel` module. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/setup.py new/WebTest-1.3.3/setup.py --- old/WebTest-1.3/setup.py 2011-08-28 16:18:34.000000000 +0200 +++ new/WebTest-1.3.3/setup.py 2011-11-21 15:01:33.000000000 +0100 @@ -4,7 +4,7 @@ import sys import os -version = '1.3' +version = '1.3.3' setup(name='WebTest', version=version, @@ -28,6 +28,7 @@ "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", ], keywords='wsgi test unit tests web', author='Ian Bicking', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_click.py new/WebTest-1.3.3/tests/test_click.py --- old/WebTest-1.3/tests/test_click.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_click.py 2011-09-22 19:17:10.000000000 +0200 @@ -10,7 +10,7 @@ def links_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" responses = { '/': """ <html> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_cookie.py new/WebTest-1.3.3/tests/test_cookie.py --- old/WebTest-1.3/tests/test_cookie.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_cookie.py 2011-09-22 19:17:10.000000000 +0200 @@ -6,7 +6,7 @@ def cookie_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" body = '<html><body><a href="/go/">go</a></body></html>' headers = [ ('Content-Type', 'text/html'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_file_upload.py new/WebTest-1.3.3/tests/test_file_upload.py --- old/WebTest-1.3/tests/test_file_upload.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_file_upload.py 2011-09-22 19:17:10.000000000 +0200 @@ -11,7 +11,7 @@ def single_upload_file_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" if req.method == "GET": body = to_bytes( """ @@ -58,7 +58,7 @@ def upload_binary_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" if req.method == "GET": body = to_bytes(""" <html> @@ -92,7 +92,7 @@ def multiple_upload_file_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" if req.method == "GET": body = to_bytes( """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_input.py new/WebTest-1.3.3/tests/test_input.py --- old/WebTest-1.3/tests/test_input.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_input.py 2011-09-22 19:17:10.000000000 +0200 @@ -8,7 +8,7 @@ def input_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" body = to_bytes( """ <html> @@ -38,7 +38,7 @@ def input_app_without_default(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" body = to_bytes( """ <html> @@ -69,7 +69,7 @@ def input_unicode_app(environ, start_response): req = Request(environ) - status = to_bytes("200 OK") + status = "200 OK" body =\ u(""" <html> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_select.py new/WebTest-1.3.3/tests/test_select.py --- old/WebTest-1.3/tests/test_select.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_select.py 2011-09-22 19:17:10.000000000 +0200 @@ -56,7 +56,7 @@ headers = [ ('Content-Type', 'text/html; charset=utf-8'), ('Content-Length', str(len(body)))] - start_response(to_bytes(status), headers) + start_response(status, headers) return [body] def select_app_without_default(environ, start_response): @@ -109,7 +109,7 @@ headers = [ ('Content-Type', 'text/html; charset=utf-8'), ('Content-Length', str(len(body)))] - start_response(to_bytes(status), headers) + start_response(status, headers) return [body] @@ -162,7 +162,7 @@ headers = [ ('Content-Type', 'text/html; charset=utf-8'), ('Content-Length', str(len(body)))] - start_response(to_bytes(status), headers) + start_response(status, headers) if not isinstance(body, binary_type): raise AssertionError('Body is not %s' % binary_type) return [body] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_selenium.py new/WebTest-1.3.3/tests/test_selenium.py --- old/WebTest-1.3/tests/test_selenium.py 2011-08-28 16:16:35.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_selenium.py 2011-09-23 18:25:40.000000000 +0200 @@ -5,6 +5,11 @@ import webtest from webob import exc from tests.compat import unittest +from webtest.compat import PY3 +from tests.compat import u + +#if PY3: +# raise NotImplementedError files = os.path.dirname(__file__) @@ -24,7 +29,7 @@ if os.path.isfile(filename): kw = dict(message=req.params.get('message', ''), redirect=req.params.get('redirect', '')) - resp.unicode_body = unicode(open(filename).read()) % kw + resp.unicode_body = u(open(filename).read()) % kw _, ext = os.path.splitext(filename) if ext == '.html': resp.content_type = 'text/html' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/tests/test_testing.py new/WebTest-1.3.3/tests/test_testing.py --- old/WebTest-1.3/tests/test_testing.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/tests/test_testing.py 2011-10-30 00:29:14.000000000 +0200 @@ -1,13 +1,30 @@ +# -*- coding: utf-8 -*- import webtest from webtest.debugapp import debug_app from webtest.compat import to_bytes +from webtest.compat import print_stderr from tests.compat import unittest +from tests.compat import u +import webbrowser + + + +def test_print_unicode(): + print_stderr(u('°C')) + class TestTesting(unittest.TestCase): def setUp(self): self.app = webtest.TestApp(debug_app) + def test_url_class(self): + class U: + def __str__(self): + return '/' + res = self.app.get(U()) + self.assertEqual(res.status_int, 200) + def test_testing(self): res = self.app.get('/') self.assertEqual(res.status_int, 200) @@ -23,20 +40,53 @@ self.assertTrue(res.content_length > 0) self.assertEqual(res.body, to_bytes('')) + def test_post_unicode(self): + res = self.app.post('/', params=dict(a=u('é')), + content_type='application/x-www-form-urlencoded;charset=utf8') + res.mustcontain('a=%C3%A9') + def test_get_params(self): res = self.app.post('/', params=dict(a=1)) res.mustcontain('a=1') res = self.app.post('/', params=[('a','1')]) res.mustcontain('a=1') + res = self.app.post_json('/', params=dict(a=1)) + res.mustcontain('{"a": 1}') + + def test_put_params(self): + res = self.app.put('/', params=dict(a=1)) + res.mustcontain('a=1') + res = self.app.put_json('/', params=dict(a=1)) + res.mustcontain('{"a": 1}') def test_delete_params(self): res = self.app.delete('/', params=dict(a=1)) res.mustcontain('a=1') + res = self.app.delete_json('/', params=dict(a=1)) + res.mustcontain('{"a": 1}') + + def test_options(self): + res = self.app.options('/') + self.assertEqual(res.status_int, 200) def test_exception(self): self.assertRaises(Exception, self.app.get, '/?error=t') self.assertRaises(webtest.AppError, self.app.get, '/?status=404%20Not%20Found') + def test_request_obj(self): + res = self.app.get('/') + res = self.app.request(res.request) + + def test_showbrowser(self): + open_new = webbrowser.open_new + self.filename = '' + def open_new(f): + self.filename = f + webbrowser.open_new = open_new + res = self.app.get('/') + res.showbrowser() + assert self.filename.startswith('file://'), self.filename + def test_303(self): res = self.app.get('/?status=303%20Redirect&header-location=/foo') self.assertEqual(res.status_int, 303) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/webtest/app.py new/WebTest-1.3.3/webtest/app.py --- old/WebTest-1.3/webtest/app.py 2011-08-27 18:57:54.000000000 +0200 +++ new/WebTest-1.3.3/webtest/app.py 2011-10-30 00:28:48.000000000 +0200 @@ -33,6 +33,8 @@ from webtest.compat import to_string from webtest.compat import to_bytes from webtest.compat import join_bytes +from webtest.compat import dumps +from webtest.compat import loads from webtest.compat import PY3 from webob import Request, Response @@ -44,15 +46,6 @@ __all__ = ['TestApp', 'TestRequest'] -def tempnam_no_warning(*args): - """ - An os.tempnam with the warning turned off, because sometimes - you just need to use this and don't care about the stupid - security warning. - """ - return os.tempnam(*args) - - class NoDefault(object): pass @@ -88,6 +81,7 @@ Instances of this class are return by ``TestApp`` """ + request = None _forms_indexed = None def forms__get(self): @@ -449,13 +443,13 @@ for s in strings: if not s in self: print_stderr("Actual response (no %r):" % s) - print_stderr(self) + print_stderr(str(self)) raise IndexError( "Body does not contain string %r" % s) for no_s in no: if no_s in self: print_stderr("Actual response (has %r)" % no_s) - print_stderr(self) + print_stderr(str(self)) raise IndexError( "Body contains bad string %r" % no_s) @@ -593,14 +587,9 @@ raise AttributeError( "Not a JSON response body (content-type: %s)" % self.content_type) - try: - from simplejson import loads - except ImportError: - try: - from json import loads - except ImportError: - raise ImportError( - "You must have simplejson installed to use response.json") + if loads is None: + raise ImportError( + "You must have simplejson installed to use response.json") return loads(self.testbody) json = property(json, doc=json.__doc__) @@ -632,11 +621,19 @@ when it's hard to read the HTML). """ import webbrowser - fn = tempnam_no_warning(None, 'webtest-page') + '.html' - f = open(fn, 'wb') - f.write(self.body) + import tempfile + f = tempfile.NamedTemporaryFile(prefix='webtest-page', + suffix='.html') + name = f.name + f.close() + f = open(name, 'w') + f.write(to_string(self.body)) f.close() - url = 'file:' + fn.replace(os.sep, '/') + if name[0] != '/': + # windows ... + url = 'file:///' + name + else: + url = 'file://' + name webbrowser.open_new(url) @@ -735,6 +732,7 @@ environ = self._make_environ(extra_environ) # Hide from py.test: __tracebackhide__ = True + url = str(url) url = self._remove_fragment(url) if params: if not isinstance(params, string_types): @@ -744,7 +742,6 @@ else: url += '?' url += params - url = str(url) if '?' in url: url, environ['QUERY_STRING'] = url.split('?', 1) else: @@ -763,10 +760,7 @@ """ environ = self._make_environ(extra_environ) # @@: Should this be all non-strings? - if isinstance(params, (list, tuple, dict)): - params = urlencode(params, doseq=True) - if hasattr(params, 'items'): - params = urlencode(params.items(), doseq=True) + params = encode_params(params, content_type) if upload_files or \ (content_type and to_string(content_type).startswith('multipart')): params = cgi.parse_qsl(params, keep_blank_values=True) @@ -812,11 +806,29 @@ expect_errors=expect_errors, content_type=content_type) + def post_json(self, url, params='', headers=None, extra_environ=None, + status=None, expect_errors=False): + """ + Do a POST request. Very like the ``.get()`` method. + ``params`` are dumps to json and put in the body of the request. + Content-Type is set to ``application/json``. + + Returns a ``webob.Response`` object. + """ + content_type = 'application/json' + if params: + params = dumps(params) + return self._gen_request('POST', url, params=params, headers=headers, + extra_environ=extra_environ, status=status, + upload_files=None, + expect_errors=expect_errors, + content_type=content_type) + def put(self, url, params='', headers=None, extra_environ=None, status=None, upload_files=None, expect_errors=False, content_type=None): """ - Do a PUT request. Very like the ``.put()`` method. + Do a PUT request. Very like the ``.post()`` method. ``params`` are put in the body of the request, if params is a tuple, dictionary, list, or iterator it will be urlencoded and placed in the body as with a POST, if it is string it will not @@ -830,10 +842,46 @@ expect_errors=expect_errors, content_type=content_type) + def put_json(self, url, params='', headers=None, extra_environ=None, + status=None, expect_errors=False): + """ + Do a PUT request. Very like the ``.post()`` method. + ``params`` are dumps to json and put in the body of the request. + Content-Type is set to ``application/json``. + + Returns a ``webob.Response`` object. + """ + content_type = 'application/json' + if params: + params = dumps(params) + return self._gen_request('PUT', url, params=params, headers=headers, + extra_environ=extra_environ, status=status, + upload_files=None, + expect_errors=expect_errors, + content_type=content_type) + def delete(self, url, params='', headers=None, extra_environ=None, + status=None, expect_errors=False, content_type=None): + """ + Do a DELETE request. Very like the ``.get()`` method. + + Returns a ``webob.Response`` object. + """ + if params: + warnings.warn(('You are not supposed to send a body in a ' + 'DELETE request. Most web servers will ignore it'), + lint.WSGIWarning) + return self._gen_request('DELETE', url, params=params, headers=headers, + extra_environ=extra_environ, status=status, + upload_files=None, + expect_errors=expect_errors, + content_type=content_type) + + def delete_json(self, url, params='', headers=None, extra_environ=None, status=None, expect_errors=False): """ Do a DELETE request. Very like the ``.get()`` method. + Content-Type is set to ``application/json``. Returns a ``webob.Response`` object. """ @@ -841,9 +889,25 @@ warnings.warn(('You are not supposed to send a body in a ' 'DELETE request. Most web servers will ignore it'), lint.WSGIWarning) + content_type = 'application/json' + if params: + params = dumps(params) return self._gen_request('DELETE', url, params=params, headers=headers, extra_environ=extra_environ, status=status, upload_files=None, + expect_errors=expect_errors, + content_type=content_type) + + def options(self, url, headers=None, extra_environ=None, + status=None, expect_errors=False): + """ + Do a OPTIONS request. Very like the ``.get()`` method. + + Returns a ``webob.Response`` object. + """ + return self._gen_request('OPTIONS', url, headers=headers, + extra_environ=extra_environ, status=status, + upload_files=None, expect_errors=expect_errors) def head(self, url, headers=None, extra_environ=None, @@ -990,6 +1054,7 @@ end_time = time.time() finally: sys.stdout = old_stdout + res.request = req res.app = app res.test_app = self # We do this to make sure the app_iter is exausted: @@ -1702,3 +1767,21 @@ ('&', '&')]: v = v.replace(ent, repl) return v + +def encode_params(params, content_type): + if isinstance(params, dict) or hasattr(params, 'items'): + params = list(params.items()) + if isinstance(params, (list, tuple)): + if content_type: + content_type = content_type.lower() + if 'charset=' in content_type: + charset = content_type.split('charset=')[1] + charset = charset.strip('; ').lower() + encoded_params = [] + for k, v in params: + if isinstance(v, text_type): + v = v.encode(charset) + encoded_params.append((k, v)) + params = encoded_params + params = urlencode(params, doseq=True) + return params diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/webtest/compat.py new/WebTest-1.3.3/webtest/compat.py --- old/WebTest-1.3/webtest/compat.py 2011-08-27 18:22:26.000000000 +0200 +++ new/WebTest-1.3.3/webtest/compat.py 2011-10-30 00:16:13.000000000 +0200 @@ -6,6 +6,8 @@ string_types = (str,) text_type = str binary_type = bytes + from json import loads + from json import dumps from io import StringIO from io import BytesIO from urllib.parse import urlencode @@ -53,6 +55,16 @@ from StringIO import StringIO BytesIO = StringIO import urlparse + try: + from json import loads + from json import dumps + except ImportError: + try: + from simplejson import loads + from simplejson import dumps + except ImportError: + loads = None + dumps = None def to_bytes(s): return str(s) @@ -69,4 +81,10 @@ if PY3: exec('print(value, file=sys.stderr)') else: - exec('print >> sys.stderr, value') + if isinstance(value, text_type): + # not really clean but this must *never* fail + try: + value = value.encode('utf-8') + except: + value = repr(value) + sys.stderr.write(value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/webtest/debugapp.py new/WebTest-1.3.3/webtest/debugapp.py --- old/WebTest-1.3/webtest/debugapp.py 2011-08-27 15:03:56.000000000 +0200 +++ new/WebTest-1.3.3/webtest/debugapp.py 2011-09-22 19:17:10.000000000 +0200 @@ -46,7 +46,7 @@ header_name = name[len('header-'):] headers.append((header_name, value)) - start_response(to_bytes(str(status)), headers) + start_response(str(status), headers) if req.method == 'HEAD': return [to_bytes('')] return [body] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WebTest-1.3/webtest/sel.py new/WebTest-1.3.3/webtest/sel.py --- old/WebTest-1.3/webtest/sel.py 2011-08-28 16:17:28.000000000 +0200 +++ new/WebTest-1.3.3/webtest/sel.py 2011-09-23 18:43:06.000000000 +0200 @@ -28,6 +28,7 @@ from webtest import app as testapp from wsgiref import simple_server from contextlib import contextmanager +from webtest.compat import PY3 from webtest.compat import urlencode from webtest.compat import binary_type from webtest.compat import HTTPConnection @@ -49,7 +50,6 @@ except NameError: unicode = str - log = logging.getLogger(__name__) @@ -110,7 +110,10 @@ try: yield response finally: - resp.body = app.browser.getHtmlSource() + body = app.browser.getHtmlSource() + if PY3: + body = body.encode(resp.charset or 'utf-8') + resp.body = body resp._forms_indexed = None resp.updated = True app.close() @@ -189,6 +192,8 @@ data = resp.read() finally: conn.close() + if PY3: + data = str(data, 'utf-8') if data.startswith('ERROR: Unknown command:'): raise AttributeError(repr(data)) elif not data.startswith('OK'): @@ -388,6 +393,8 @@ def _body__get(self): body = self.browser.getHtmlSource() + if PY3: + return body.encode(self.charset or 'utf-8') if isinstance(body, binary_type): return unicode(body, self.charset or 'utf-8') else: @@ -849,11 +856,13 @@ body = open(filename).read() body.replace('http://localhost/', 'http://%s/' % req.host) - resp.body = body + if PY3: + resp.text = body + else: + resp.body = body return resp(environ, start_response) elif '__application__' in environ['PATH_INFO']: resp = webob.Response() - resp.body = 'Application running' return resp(environ, start_response) return self.app(environ, start_response) -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org