Does this work for Windows config file paths?
This commit is contained in:
+5
-1
@@ -1,6 +1,7 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -39,7 +40,10 @@ FREQUENCY = FrequencyParamType()
|
|||||||
|
|
||||||
|
|
||||||
def config_file():
|
def config_file():
|
||||||
return os.path.expanduser('~/.config/sucks.conf')
|
if platform.system() == 'Windows':
|
||||||
|
return os.path.join(os.getenv('APPDATA'), 'sucks.conf')
|
||||||
|
else:
|
||||||
|
return os.path.expanduser('~/.config/sucks.conf')
|
||||||
|
|
||||||
|
|
||||||
def config_file_exists():
|
def config_file_exists():
|
||||||
|
|||||||
@@ -4,6 +4,20 @@ from nose.tools import *
|
|||||||
from sucks.cli import *
|
from sucks.cli import *
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_file_name():
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
print(config_file())
|
||||||
|
assert_true(re.match(r'[A-Z]:\\.+\\\w+\\AppData\\sucks.conf', config_file()))
|
||||||
|
else:
|
||||||
|
assert_true(re.match(r'/.+/\w+/.config/sucks.conf', config_file()))
|
||||||
|
|
||||||
|
|
||||||
|
# def test_write_and_read_config():
|
||||||
|
# config1 = {'a':1, 'b':2}
|
||||||
|
# write_config(config1)
|
||||||
|
# config2 = read_config()
|
||||||
|
# assert_equals(config1, config2)
|
||||||
|
|
||||||
def test_frequency_param_type():
|
def test_frequency_param_type():
|
||||||
t = FREQUENCY
|
t = FREQUENCY
|
||||||
assert_equals(t.convert('0', None, None), 0)
|
assert_equals(t.convert('0', None, None), 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user