aboutsummaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-11-08 16:44:21 +0800
committerMicah Lee <micah@micahflee.com>2019-11-08 16:44:21 +0800
commite18d2c3ea278f9e6208423a3ba2295ca9178355f (patch)
tree7e0ef91d262594678f6f900739b39814454e2d74 /onionshare
parenteee1fa4e801714ea761832e03aab4d4ca07c04d8 (diff)
downloadonionshare-e18d2c3ea278f9e6208423a3ba2295ca9178355f.tar.gz
onionshare-e18d2c3ea278f9e6208423a3ba2295ca9178355f.zip
Add CLI tests in
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/common.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/onionshare/common.py b/onionshare/common.py
index cf713818..e85403eb 100644
--- a/onionshare/common.py
+++ b/onionshare/common.py
@@ -159,23 +159,24 @@ class Common:
"""
Returns the path of the OnionShare data directory.
"""
- if getattr(sys, "onionshare_test_mode", False):
- onionshare_data_dir = os.path.expanduser("~/.config/onionshare-testdata")
- else:
- if self.platform == "Windows":
- try:
- appdata = os.environ["APPDATA"]
- onionshare_data_dir = f"{appdata}\\OnionShare"
- except:
- # If for some reason we don't have the 'APPDATA' environment variable
- # (like running tests in Linux while pretending to be in Windows)
- onionshare_data_dir = os.path.expanduser("~/.config/onionshare")
- elif self.platform == "Darwin":
- onionshare_data_dir = os.path.expanduser(
- "~/Library/Application Support/OnionShare"
- )
- else:
+ if self.platform == "Windows":
+ try:
+ appdata = os.environ["APPDATA"]
+ onionshare_data_dir = f"{appdata}\\OnionShare"
+ except:
+ # If for some reason we don't have the 'APPDATA' environment variable
+ # (like running tests in Linux while pretending to be in Windows)
onionshare_data_dir = os.path.expanduser("~/.config/onionshare")
+ elif self.platform == "Darwin":
+ onionshare_data_dir = os.path.expanduser(
+ "~/Library/Application Support/OnionShare"
+ )
+ else:
+ onionshare_data_dir = os.path.expanduser("~/.config/onionshare")
+
+ # Modify the data dir if running tests
+ if getattr(sys, "onionshare_test_mode", False):
+ onionshare_data_dir += "-testdata"
os.makedirs(onionshare_data_dir, 0o700, True)
return onionshare_data_dir