fix tests for python 2.7
This commit is contained in:
parent
5dd65ffa03
commit
6c929dbafa
@ -141,6 +141,7 @@ class SandboxedCommandTestCase(unittest.TestCase):
|
||||
def _preprocess_cmd(self, cmd):
|
||||
"""Sandbox the pubs command into a temporary directory"""
|
||||
cmd_chunks = cmd.split(' ')
|
||||
print(cmd, cmd_chunks[0], 'pubs')
|
||||
assert cmd_chunks[0] == 'pubs'
|
||||
prefix = ['pubs', '-c', self.default_conf_path]
|
||||
if cmd_chunks[1] == 'init':
|
||||
@ -163,17 +164,16 @@ class SandboxedCommandTestCase(unittest.TestCase):
|
||||
for cmd in cmds:
|
||||
inputs = []
|
||||
expected_out, expected_err = None, None
|
||||
actual_cmd = cmd
|
||||
if not isinstance(cmd, p3.ustr):
|
||||
actual_cmd = cmd[0]
|
||||
if len(cmd) >= 2 and cmd[1] is not None: # Inputs provided
|
||||
inputs = cmd[1]
|
||||
if len(cmd) >= 3: # Expected output provided
|
||||
capture_output = True
|
||||
if cmd[2] is not None:
|
||||
expected_out = color.undye(cmd[2])
|
||||
if len(cmd) >= 4 and cmd[3] is not None: # Expected error output provided
|
||||
expected_err = color.undye(cmd[3])
|
||||
assert isinstance(cmd, tuple)
|
||||
actual_cmd = cmd[0]
|
||||
if len(cmd) >= 2 and cmd[1] is not None: # Inputs provided
|
||||
inputs = cmd[1]
|
||||
if len(cmd) >= 3: # Expected output provided
|
||||
capture_output = True
|
||||
if cmd[2] is not None:
|
||||
expected_out = color.undye(cmd[2])
|
||||
if len(cmd) >= 4 and cmd[3] is not None: # Expected error output provided
|
||||
expected_err = color.undye(cmd[3])
|
||||
actual_cmd = self._preprocess_cmd(actual_cmd)
|
||||
# Always set fake input: test should not ask unexpected user input
|
||||
input = FakeInput(inputs, [content, uis, p3])
|
||||
@ -242,7 +242,7 @@ class TestSandboxedCommandTestCase(SandboxedCommandTestCase):
|
||||
"""Simple init and add example"""
|
||||
correct = ("added to pubs:\n"
|
||||
"[Page99] Page, Lawrence et al. \"The PageRank Citation Ranking: Bringing Order to the Web.\" (1999) \n")
|
||||
cmds = ['pubs init',
|
||||
cmds = [('pubs init',),
|
||||
('pubs add data/pagerank.bib', [], correct),
|
||||
#('pubs add abc', [], '', 'error: File does not exist: /Users/self/Volumes/ResearchSync/projects/pubs/abc\n')
|
||||
]
|
||||
|
@ -16,34 +16,34 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
||||
|
||||
def setUp(self, nsec_stat=True):
|
||||
super(TestGitPlugin, self).setUp()
|
||||
self.execute_cmds(['pubs init'])
|
||||
self.execute_cmds([('pubs init',)])
|
||||
conf = config.load_conf(path=self.default_conf_path)
|
||||
conf['plugins']['active'] = ['git']
|
||||
config.save_conf(conf, path=self.default_conf_path)
|
||||
|
||||
def test_git(self):
|
||||
self.execute_cmds(['pubs add data/pagerank.bib'])
|
||||
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
||||
hash_a = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds(['pubs add data/pagerank.bib'])
|
||||
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
||||
hash_b = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds(['pubs rename Page99a ABC'])
|
||||
self.execute_cmds([('pubs rename Page99a ABC',)])
|
||||
hash_c = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds([('pubs remove ABC', ['y']),])
|
||||
hash_d = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds(['pubs doc add testrepo/doc/Page99.pdf Page99'])
|
||||
self.execute_cmds([('pubs doc add testrepo/doc/Page99.pdf Page99',)])
|
||||
hash_e = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds([('pubs doc remove Page99', ['y'])])
|
||||
hash_f = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds(['pubs tag Page99 bla+bli'])
|
||||
self.execute_cmds([('pubs tag Page99 bla+bli',)])
|
||||
hash_g = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds(['pubs list'])
|
||||
self.execute_cmds([('pubs list',)])
|
||||
hash_h = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds([('pubs edit Page99', ['@misc{Page99, title="TTT" author="X. YY"}', 'y',
|
||||
@ -63,7 +63,7 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
||||
conf['plugins']['active'] = []
|
||||
config.save_conf(conf, path=self.default_conf_path)
|
||||
|
||||
self.execute_cmds(['pubs add data/pagerank.bib'])
|
||||
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
||||
hash_j = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.assertEqual(hash_i, hash_j)
|
||||
@ -73,17 +73,17 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
||||
conf['plugins']['git']['manual'] = True
|
||||
config.save_conf(conf, path=self.default_conf_path)
|
||||
|
||||
self.execute_cmds(['pubs add data/pagerank.bib'])
|
||||
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
||||
hash_k = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.assertEqual(hash_j, hash_k)
|
||||
|
||||
self.execute_cmds(['pubs git add .'])
|
||||
self.execute_cmds([('pubs git add .',)])
|
||||
hash_l = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.assertEqual(hash_k, hash_l)
|
||||
|
||||
self.execute_cmds(['pubs git commit -m "abc"'])
|
||||
self.execute_cmds([('pubs git commit -m "abc"',)])
|
||||
hash_m = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.assertNotEqual(hash_l, hash_m)
|
||||
|
Loading…
x
Reference in New Issue
Block a user