diff options
-rwxr-xr-x | pyactivitypubd | 2 | ||||
-rw-r--r-- | pyapd/config.py | 9 | ||||
-rw-r--r-- | tests/test_config.py | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/pyactivitypubd b/pyactivitypubd index 97786bb..4d9e63e 100755 --- a/pyactivitypubd +++ b/pyactivitypubd @@ -6,7 +6,7 @@ from pyapd import app, config if __name__ == "__main__": - config = config.Config + config = config.Config() apd = app.App(config) apd.listen(8888) tornado.ioloop.IOLoop.current().start() diff --git a/pyapd/config.py b/pyapd/config.py index 83e35b4..fd01435 100644 --- a/pyapd/config.py +++ b/pyapd/config.py @@ -7,8 +7,7 @@ class Config(): def __init__(self, config_fn: Optional[str] = None, **kw): self.config_fn = config_fn self.data: dict = {} - if config_fn: - self.load() + self.load() def __getattr__(self, name): try: @@ -16,6 +15,12 @@ class Config(): except KeyError as e: raise NameError(e) + def __str__(self): + return "<pyapd configuration from {}>".format(self.config_fn) + + def __repr__(self): + return str(self.data) + def load(self, config_fn: Optional[str] = None): if config_fn: self.config_fn = config_fn diff --git a/tests/test_config.py b/tests/test_config.py index 6002dd9..507c322 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -8,7 +8,6 @@ class TestConfig(unittest.TestCase): self.config = config.Config() def test_load_config_no_files(self): - self.config.load() self.assertEqual(self.config.config_fn, 'pyapd_config.yaml') self.assertIn('backend', self.config.data) |