Syntax highlighting
This commit is contained in:
20
tests/user_data_test.py
Normal file
20
tests/user_data_test.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
from babi.user_data import xdg_data
|
||||
|
||||
|
||||
def test_when_xdg_data_home_is_set():
|
||||
with mock.patch.dict(os.environ, {'XDG_DATA_HOME': '/foo'}):
|
||||
ret = xdg_data('history', 'command')
|
||||
assert ret == '/foo/babi/history/command'
|
||||
|
||||
|
||||
def test_when_xdg_data_home_is_not_set():
|
||||
def fake_expanduser(s):
|
||||
return s.replace('~', '/home/username')
|
||||
|
||||
with mock.patch.object(os.path, 'expanduser', fake_expanduser):
|
||||
with mock.patch.dict(os.environ, clear=True):
|
||||
ret = xdg_data('history')
|
||||
assert ret == '/home/username/.local/share/babi/history'
|
||||
Reference in New Issue
Block a user