From: Cory Benfield Date: Wed, 8 Aug 2012 10:59:00 +0000 (+0100) Subject: Add test for Issue #423. X-Git-Tag: v0.13.7~14^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e624ae8aeadc63b473e1d57f1bec71b4f713cf32;p=services%2Fpython-requests.git Add test for Issue #423. --- diff --git a/tests/test_requests.py b/tests/test_requests.py index dd08b2a..f7803ba 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -996,5 +996,23 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase): first_line = next(req.response.iter_lines()) self.assertTrue(first_line.strip().decode('utf-8').startswith('{')) + def test_accept_objects_with_string_representations_as_urls(self): + """Test that URLs can be set to objects with string representations, + e.g. for use with furl.""" + class URL(): + def __unicode__(self): + # Can't have unicode literals in Python3, so avoid them. + # TODO: fixup when moving to Python 3.3 + if (sys.version_info[0] == 2): + return 'http://httpbin.org/get'.decode('utf-8') + else: + return 'http://httpbin.org/get' + + def __str__(self): + return 'http://httpbin.org/get' + + r = get(URL()) + self.assertEqual(r.status_code, 200) + if __name__ == '__main__': unittest.main()