def tearDown(self): if self._orig_server_addr: os.environ[hatoholserver.SERVER_ADDR_ENV_NAME] = self._orig_server_addr self._orig_server_addr = None elif hatoholserver.SERVER_ADDR_ENV_NAME in os.environ: del os.environ[hatoholserver.SERVER_ADDR_ENV_NAME] if self._orig_server_port: os.environ[hatoholserver.SERVER_PORT_ENV_NAME] = self._orig_server_port self._orig_server_port = None elif hatoholserver.SERVER_PORT_ENV_NAME in os.environ: del os.environ[hatoholserver.SERVER_PORT_ENV_NAME] hatoholserver._setup() # Update the internal information
def tearDown(self): if self._orig_server_addr: os.environ[ hatoholserver.SERVER_ADDR_ENV_NAME] = self._orig_server_addr self._orig_server_addr = None elif hatoholserver.SERVER_ADDR_ENV_NAME in os.environ: del os.environ[hatoholserver.SERVER_ADDR_ENV_NAME] if self._orig_server_port: os.environ[ hatoholserver.SERVER_PORT_ENV_NAME] = self._orig_server_port self._orig_server_port = None elif hatoholserver.SERVER_PORT_ENV_NAME in os.environ: del os.environ[hatoholserver.SERVER_PORT_ENV_NAME] hatoholserver._setup() # Update the internal information
def test_get_address_with_env(self): os.environ[hatoholserver.SERVER_PORT_ENV_NAME] = '12345' hatoholserver._setup() # Update the internal information addr = self.assertEqual(hatoholserver.get_port(), 12345)
def test_get_default_port(self): if os.getenv(hatoholserver.SERVER_PORT_ENV_NAME): del os.environ[hatoholserver.SERVER_PORT_ENV_NAME] hatoholserver._setup() # Update the internal information addr = self.assertEqual(hatoholserver.get_port(), hatoholserver.DEFAULT_SERVER_PORT)
def test_get_address_with_env(self): os.environ[hatoholserver.SERVER_ADDR_ENV_NAME] = 'foo.example.com' hatoholserver._setup() # Update the internal information addr = self.assertEqual(hatoholserver.get_address(), 'foo.example.com')
def test_get_default_address(self): if os.getenv(hatoholserver.SERVER_ADDR_ENV_NAME): del os.environ[hatoholserver.SERVER_ADDR_ENV_NAME] hatoholserver._setup() # Update the internal information addr = self.assertEqual(hatoholserver.get_address(), 'localhost')