tests can be run from root dir
This commit is contained in:
parent
3b7900a3a4
commit
04fcb42338
@ -65,13 +65,15 @@ def _create_fake_fs():
|
|||||||
|
|
||||||
def _copy_data(fs):
|
def _copy_data(fs):
|
||||||
"""Copy all the data directory into the fake fs"""
|
"""Copy all the data directory into the fake fs"""
|
||||||
for filename in real_os.listdir('data/'):
|
datadir = real_os.path.join(real_os.path.dirname(__file__), 'data')
|
||||||
filepath = 'data/' + filename
|
for filename in real_os.listdir(datadir):
|
||||||
if real_os.path.isfile(filepath):
|
real_path = real_os.path.join(datadir, filename)
|
||||||
with real_open(filepath, 'r') as f:
|
fake_path = fake_os.path.join('data', filename)
|
||||||
fs.CreateFile(filepath, contents = f.read())
|
if real_os.path.isfile(real_path):
|
||||||
if real_os.path.isdir(filepath):
|
with real_open(real_path, 'r') as f:
|
||||||
fs.CreateDirectory(filepath)
|
fs.CreateFile(fake_path, contents = f.read())
|
||||||
|
if real_os.path.isdir(real_path):
|
||||||
|
fs.CreateDirectory(fake_path)
|
||||||
|
|
||||||
|
|
||||||
# redirecting output
|
# redirecting output
|
||||||
@ -142,6 +144,7 @@ def _execute_cmds(cmds, fs = None):
|
|||||||
fs = _create_fake_fs()
|
fs = _create_fake_fs()
|
||||||
_copy_data(fs)
|
_copy_data(fs)
|
||||||
|
|
||||||
|
|
||||||
outs = []
|
outs = []
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
if hasattr(cmd, '__iter__'):
|
if hasattr(cmd, '__iter__'):
|
||||||
@ -287,19 +290,20 @@ class TestUsecase(unittest.TestCase):
|
|||||||
|
|
||||||
_execute_cmds(cmds)
|
_execute_cmds(cmds)
|
||||||
|
|
||||||
def test_editor(self):
|
def test_editor_abort(self):
|
||||||
|
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
cmds = ['papers init',
|
cmds = ['papers init',
|
||||||
('papers add', ['abc', 'n'])
|
('papers add', ['abc', 'n'])
|
||||||
]
|
]
|
||||||
|
|
||||||
_execute_cmds(cmds)
|
_execute_cmds(cmds)
|
||||||
|
|
||||||
|
# def test_editor_success(self):
|
||||||
# if __name__ == "__main__":
|
# with real_open('data/', 'r')
|
||||||
# cmds = ['papers init',
|
#
|
||||||
# 'papers add', ['', 'n']]
|
# cmds = ['papers init',
|
||||||
#
|
# ('papers add', ['abc', 'n'])
|
||||||
# _execute_cmds(cmds)
|
# ]
|
||||||
|
#
|
||||||
|
# _execute_cmds(cmds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user