test.py 855 B

1234567891011121314151617181920212223242526272829303132
  1. '''
  2. Created on Jan 5, 2012
  3. @author: philipkershaw
  4. '''
  5. import unittest
  6. from ndg.httpsclient.urllib2_build_opener import urllib2_build_opener
  7. from ndg.httpsclient.https import HTTPSConnection
  8. class Urllib2PyOpenSslTestCase(unittest.TestCase):
  9. """Unit tests for PyOpenSSL HTTPS interface for urllib2"""
  10. TEST_URI = 'https://localhost:4443'
  11. def test01_httpsconnection(self):
  12. conn = HTTPSConnection('localhost', port=4443)
  13. conn.connect()
  14. conn.close()
  15. def test02_urllib2_build_opener(self):
  16. opener = urllib2_build_opener()
  17. self.assert_(opener)
  18. def test03_open(self):
  19. opener = urllib2_build_opener()
  20. res = opener.open(self.__class__.TEST_URI)
  21. self.assert_(res)
  22. print("res = %s" % res.read())
  23. if __name__ == "__main__":
  24. unittest.main()