Autoformat py files using Black (#105)
* Autoformat all py files using Black
* Fix lint errors
* Fix indentation errors (https://travis-ci.org/httplib2/httplib2/jobs/408136309)
* Refactor three test cases and exclude them on on Travis py27/pypy
diff --git a/python2/httplib2test_appengine.py b/python2/httplib2test_appengine.py
index 9fad05a..d5c5786 100755
--- a/python2/httplib2test_appengine.py
+++ b/python2/httplib2test_appengine.py
@@ -5,11 +5,12 @@
import sys
import unittest
-APP_ENGINE_PATH='/usr/local/google_appengine'
+APP_ENGINE_PATH = "/usr/local/google_appengine"
sys.path.insert(0, APP_ENGINE_PATH)
import dev_appserver
+
dev_appserver.fix_sys_path()
from google.appengine.ext import testbed
@@ -20,60 +21,65 @@
class AberrationsTest(unittest.TestCase):
+ def setUp(self):
+ self.testbed = testbed.Testbed()
+ self.testbed.activate()
+ self.testbed.init_urlfetch_stub()
- def setUp(self):
- self.testbed = testbed.Testbed()
- self.testbed.activate()
- self.testbed.init_urlfetch_stub()
+ def tearDown(self):
+ self.testbed.deactivate()
- def tearDown(self):
- self.testbed.deactivate()
+ @mock.patch.dict("os.environ", {"SERVER_SOFTWARE": ""})
+ def testConnectionInit(self):
+ global httplib2
+ import httplib2
- @mock.patch.dict('os.environ', {'SERVER_SOFTWARE': ''})
- def testConnectionInit(self):
- global httplib2
- import httplib2
- self.assertNotEqual(
- httplib2.SCHEME_TO_CONNECTION['https'], httplib2.AppEngineHttpsConnection)
- self.assertNotEqual(
- httplib2.SCHEME_TO_CONNECTION['http'], httplib2.AppEngineHttpConnection)
- del globals()['httplib2']
+ self.assertNotEqual(
+ httplib2.SCHEME_TO_CONNECTION["https"], httplib2.AppEngineHttpsConnection
+ )
+ self.assertNotEqual(
+ httplib2.SCHEME_TO_CONNECTION["http"], httplib2.AppEngineHttpConnection
+ )
+ del globals()["httplib2"]
class AppEngineHttpTest(unittest.TestCase):
+ def setUp(self):
+ self.testbed = testbed.Testbed()
+ self.testbed.activate()
+ self.testbed.init_urlfetch_stub()
+ global httplib2
+ import httplib2
- def setUp(self):
- self.testbed = testbed.Testbed()
- self.testbed.activate()
- self.testbed.init_urlfetch_stub()
- global httplib2
- import httplib2
- reload(httplib2)
+ reload(httplib2)
- def tearDown(self):
- self.testbed.deactivate()
- del globals()['httplib2']
+ def tearDown(self):
+ self.testbed.deactivate()
+ del globals()["httplib2"]
- def testConnectionInit(self):
- self.assertEqual(
- httplib2.SCHEME_TO_CONNECTION['https'], httplib2.AppEngineHttpsConnection)
- self.assertEqual(
- httplib2.SCHEME_TO_CONNECTION['http'], httplib2.AppEngineHttpConnection)
+ def testConnectionInit(self):
+ self.assertEqual(
+ httplib2.SCHEME_TO_CONNECTION["https"], httplib2.AppEngineHttpsConnection
+ )
+ self.assertEqual(
+ httplib2.SCHEME_TO_CONNECTION["http"], httplib2.AppEngineHttpConnection
+ )
- def testGet(self):
- http = httplib2.Http()
- response, content = http.request("http://www.google.com")
- self.assertEqual(httplib2.SCHEME_TO_CONNECTION['https'],
- httplib2.AppEngineHttpsConnection)
- self.assertEquals(1, len(http.connections))
- self.assertEquals(response.status, 200)
- self.assertEquals(response['status'], '200')
+ def testGet(self):
+ http = httplib2.Http()
+ response, content = http.request("http://www.google.com")
+ self.assertEqual(
+ httplib2.SCHEME_TO_CONNECTION["https"], httplib2.AppEngineHttpsConnection
+ )
+ self.assertEquals(1, len(http.connections))
+ self.assertEquals(response.status, 200)
+ self.assertEquals(response["status"], "200")
- def testProxyInfoIgnored(self):
- http = httplib2.Http(proxy_info=mock.MagicMock())
- response, content = http.request("http://www.google.com")
- self.assertEquals(response.status, 200)
+ def testProxyInfoIgnored(self):
+ http = httplib2.Http(proxy_info=mock.MagicMock())
+ response, content = http.request("http://www.google.com")
+ self.assertEquals(response.status, 200)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()