Commits

Gael Pasgrimaud committed 0630096

add a request attribute to TestResponse. convert url to str(). see #21

  • Participants
  • Parent commits 1d83346

Comments (0)

Files changed (2)

File tests/test_testing.py

     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)

File webtest/app.py

     Instances of this class are return by ``TestApp``
     """
 
+    request = None
     _forms_indexed = None
 
     def forms__get(self):
         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):
             else:
                 url += '?'
             url += params
-        url = str(url)
         if '?' in url:
             url, environ['QUERY_STRING'] = url.split('?', 1)
         else:
             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: