diff options
author | Micah Lee <micah@micahflee.com> | 2019-11-08 16:44:21 +0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2019-11-08 16:44:21 +0800 |
commit | e18d2c3ea278f9e6208423a3ba2295ca9178355f (patch) | |
tree | 7e0ef91d262594678f6f900739b39814454e2d74 /onionshare | |
parent | eee1fa4e801714ea761832e03aab4d4ca07c04d8 (diff) | |
download | onionshare-e18d2c3ea278f9e6208423a3ba2295ca9178355f.tar.gz onionshare-e18d2c3ea278f9e6208423a3ba2295ca9178355f.zip |
Add CLI tests in
Diffstat (limited to 'onionshare')
-rw-r--r-- | onionshare/common.py | 33 |
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 |