[tests/theme] Fix WAL mocked tests

Until now, the WAL tests depended on the pyWAL cache file being actually
present on the system.
This commit is contained in:
tobi-wan-kenobi 2020-04-13 13:47:50 +02:00
parent dc5bfd1fc6
commit 580bb20a9f

View file

@ -85,6 +85,9 @@ class theme(unittest.TestCase):
def test_wal_colors(self): def test_wal_colors(self):
with unittest.mock.patch('core.theme.io') as io: with unittest.mock.patch('core.theme.io') as io:
with unittest.mock.patch('core.theme.os') as os:
os.path.isfile.return_value = True
io.open.return_value = unittest.mock.MagicMock()
io.open.return_value.__enter__.return_value.read.return_value=''' io.open.return_value.__enter__.return_value.read.return_value='''
{ "colors": { "red": "#ff0000" } } { "colors": { "red": "#ff0000" } }
''' '''
@ -94,6 +97,8 @@ class theme(unittest.TestCase):
def test_wal_special(self): def test_wal_special(self):
with unittest.mock.patch('core.theme.io') as io: with unittest.mock.patch('core.theme.io') as io:
with unittest.mock.patch('core.theme.os') as os:
os.path.isfile.return_value = True
io.open.return_value.__enter__.return_value.read.return_value=''' io.open.return_value.__enter__.return_value.read.return_value='''
{ "special": { "background": "#ff0000" } } { "special": { "background": "#ff0000" } }
''' '''