mirror of https://github.com/docker/docker-py.git
				
				
				
			Enforce passing string as version param in ctor
This commit is contained in:
		
							parent
							
								
									0012430b1b
								
							
						
					
					
						commit
						a9bc84cece
					
				|  | @ -50,6 +50,12 @@ class Client(requests.Session): | |||
|             raise errors.TLSParameterError( | ||||
|                 'If using TLS, the base_url argument must begin with ' | ||||
|                 '"https://".') | ||||
|         if not isinstance(version, six.string_types): | ||||
|             raise errors.DockerException( | ||||
|                 'version parameter must be a string. Found {0}'.format( | ||||
|                     type(version).__name__ | ||||
|                 ) | ||||
|             ) | ||||
|         self.base_url = base_url | ||||
|         self._version = version | ||||
|         self._timeout = timeout | ||||
|  |  | |||
|  | @ -102,6 +102,17 @@ class DockerClientTest(Cleanup, unittest.TestCase): | |||
|     def tearDown(self): | ||||
|         self.client.close() | ||||
| 
 | ||||
|     def test_ctor(self): | ||||
|         try: | ||||
|             docker.Client(version=1.12) | ||||
|         except Exception as e: | ||||
|             self.assertTrue(isinstance(e, docker.errors.DockerException)) | ||||
|             if not six.PY3: | ||||
|                 self.assertEqual( | ||||
|                     e.message, | ||||
|                     'version parameter must be a string. Found float' | ||||
|                 ) | ||||
| 
 | ||||
|     ######################### | ||||
|     #   INFORMATION TESTS   # | ||||
|     ######################### | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue