def clearEnv(self): if "PYRO_HOST" in os.environ: del os.environ["PYRO_HOST"] if "PYRO_NS_PORT" in os.environ: del os.environ["PYRO_NS_PORT"] if "PYRO_COMPRESSION" in os.environ: del os.environ["PYRO_COMPRESSION"] config.reset()
def testConfig(self): self.clearEnv() try: assert config.NS_PORT == 9090 assert config.HOST == "localhost" assert config.COMPRESSION == False os.environ["NS_PORT"] = "4444" config.reset() assert config.NS_PORT == 9090 os.environ["PYRO_NS_PORT"] = "4444" os.environ["PYRO_HOST"] = "something.com" os.environ["PYRO_COMPRESSION"] = "OFF" config.reset() assert config.NS_PORT == 4444 assert config.HOST == "something.com" assert config.COMPRESSION == False finally: self.clearEnv() assert config.NS_PORT == 9090 assert config.HOST == "localhost" assert config.COMPRESSION == False
def testConfigParseBool(self): config = Pyro5.configure.Configuration() assert type(config.COMPRESSION) is bool os.environ["PYRO_COMPRESSION"] = "yes" config.reset() assert config.COMPRESSION os.environ["PYRO_COMPRESSION"] = "off" config.reset() assert not config.COMPRESSION os.environ["PYRO_COMPRESSION"] = "foobar" with pytest.raises(ValueError): config.reset() del os.environ["PYRO_COMPRESSION"] config.reset()
def testConfigReset(self): try: config.reset() assert config.HOST == "localhost" config.HOST = "foobar" assert config.HOST == "foobar" config.reset() assert config.HOST == "localhost" os.environ["PYRO_HOST"] = "foobar" config.reset() assert config.HOST == "foobar" del os.environ["PYRO_HOST"] config.reset() assert config.HOST == "localhost" finally: self.clearEnv()
def testConfigDefaults(self): # some security sensitive settings: config.reset(False) # reset the config to default assert config.HOST == "localhost" assert config.NS_HOST == "localhost" assert config.SERIALIZER == "serpent"
def teardown_method(self): config.reset()