Commit Graph

4 Commits

Author SHA1 Message Date
Ivan Habunek 59efff5abc
Use context manager to edit config
This simplies the code a bit and resolves some type hinting issues.
2023-12-17 09:42:09 +01:00
Mateusz Piotrowski beeb7914a8 Fix XDG_CONFIG_HOME tests
According to the Python documentation[1]:

> Calls to unsetenv() don’t update os.environ, so it is actually
> preferable to delete items of os.environ.

It means that os.unsetenv is not enough to remove an entry from
os.environ. This is why the following test was failing:

    os.unsetenv('XDG_CONFIG_HOME')
    assert fn() == os.path.expanduser('~/.config/toot/config.json')

os.unsetenv did not influence the output of the subsequent call to
os.getenv() in get_config_file_path(). As a result the original value
was returned instead of the fallback value of '~/.config'.

This bug was discovered during porting toot to FreeBSD as the FreeBSD
Ports framework passes XDG_CONFIG_HOME to make's environment.

[1]: https://docs.python.org/3.6/library/os.html#os.unsetenv
2018-04-17 21:09:26 +02:00
Ivan Habunek 455e531194
Respect XDG_CONFIG_HOME env variable
to locate configuration home directory.

fixes #12
2018-01-14 15:29:34 +01:00
Ivan Habunek 6a3c877270
Reimplement configuration to allow multiple logins
The configuration is now stored in a single json encoded file instead of
separate files.
2018-01-02 12:24:32 +01:00