summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gd_diff.py12
-rw-r--r--tests/test_gd_diff.py2
2 files changed, 12 insertions, 2 deletions
diff --git a/gd_diff.py b/gd_diff.py
index fccc557..384e92f 100644
--- a/gd_diff.py
+++ b/gd_diff.py
@@ -212,7 +212,17 @@ def slurp_fields_from_readme(content):
def config_dir():
- return os.path.join(os.getenv('HOME'), '.config', 'gns-deb-diff')
+ """Return the gns-deb-diff config directory.
+
+ As a side effect, the directory is created if it does not exist.
+
+ """
+ cd = os.path.join(os.getenv('HOME'), '.config', 'gns-deb-diff')
+
+ if not os.path.isdir(cd):
+ os.makedirs(cd)
+
+ return cd
def config_file():
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index e59db1a..ff092a2 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -234,6 +234,7 @@ class TestGdDiff(object):
c_dir = config_dir()
assert_equal(c_dir, os.path.join(self.test_home,
'.config', 'gns-deb-diff'))
+ assert_equal(os.path.isdir(c_dir), True)
def test_config_file(self):
@@ -263,7 +264,6 @@ class TestGdDiff(object):
c_path = config_dir()
c_file = config_file()
- os.makedirs(c_path)
open(c_file, 'w').close()
configured = configured_p()