Skip to content
Snippets Groups Projects
Commit 158db705 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Unit test for settings.filePath function

parent 772700d7
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ def test_initialise(): ...@@ -36,6 +36,7 @@ def test_initialise():
assert settings.readFile('nothing') is None assert settings.readFile('nothing') is None
settings.writeFile('nothing', 'nothing') settings.writeFile('nothing', 'nothing')
settings.deleteFile('nothing') settings.deleteFile('nothing')
assert settings.filePath() is None
assert settings.readAll() == {} assert settings.readAll() == {}
assert settings.listFiles() == [] assert settings.listFiles() == []
settings.clear() settings.clear()
...@@ -339,6 +340,28 @@ def test_listFiles(): ...@@ -339,6 +340,28 @@ def test_listFiles():
assert list(sorted(s.listFiles('*/setting1.txt'))) == list(sorted([ns1files[0]] + [ns2files[0]])) assert list(sorted(s.listFiles('*/setting1.txt'))) == list(sorted([ns1files[0]] + [ns2files[0]]))
def test_filePath():
testfiles = ['file1.txt',
'dir1/file2.txt',
'dir1/dir2/file3.txt']
with tests.testdir() as testdir:
s = settings.Settings(cfgid='test', cfgdir=testdir, writeOnExit=False)
assert s.filePath('nofile') == op.join(testdir, 'nofile')
for fn in testfiles:
s.writeFile(fn, fn)
assert s.filePath('nofile') == op.join(testdir, 'nofile')
for f in testfiles:
assert s.filePath(f) == op.join(testdir, f)
def test_clear(): def test_clear():
testsettings = [('setting1', '1'), testsettings = [('setting1', '1'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment