Commit b4a05bc2 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: test our expandvars function

parent 62f9addc
......@@ -19,12 +19,44 @@ from . import tempdir, server
import fsl.add_module.routines as routines
def test_expandvars():
tests = [
('$VAR', 'VALUE'),
('$VAR/abcde/', 'VALUE/abcde/'),
('abcde/$VAR/abcde/', 'abcde/VALUE/abcde/'),
('$VAR$VAR', 'VALUEVALUE'),
('$VAR/abcde/$VAR', 'VALUE/abcde/VALUE'),
('${VAR}', 'VALUE'),
('${VAR}/abcde/', 'VALUE/abcde/'),
('abcde/${VAR}/abcde/', 'abcde/VALUE/abcde/'),
('${VAR}${VAR}', 'VALUEVALUE'),
('${VAR}/abcde/${VAR}', 'VALUE/abcde/VALUE'),
]
with mock.patch.dict(os.environ, {'VAR' : 'VALUE'}):
for input, expected in tests:
assert routines.expandvars(input) == expected
tests = [
('$VAR', ''),
('${VAR}', ''),
('$VAR/abcde/', '/abcde/'),
('${VAR}/abcde/', '/abcde/'),
]
with mock.patch.dict(os.environ, clear=True):
for input, expected in tests:
assert routines.expandvars(input) == expected
def test_expand():
assert routines.expand('~') == os.environ['HOME']
assert routines.expand('$HOME') == os.environ['HOME']
assert routines.expand('.') == os.getcwd()
with mock.patch.dict(os.environ, clear=True):
assert routines.expand('$UNSET/dir') == '/dir'
def test_downloadFile():
with tempdir():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment