def test_hg_diff_driver(filespath, capsys, nocolor, needs_hg): # Simulate a call from `hg diff` to check basic driver functionality fn1 = pjoin(filespath, 'foo--1.ipynb') fn2 = pjoin(filespath, 'foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = ['/mock/path/hg-nbdiffdriver', fn1, fn2] with mock.patch('sys.argv', mock_argv): r = hgd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_output.format(fn1, fn2, t1, t2)
def test_hg_diff_driver_ignore_flags(filespath, capsys, needs_hg, reset_notebook_diff): # Simulate a call from `hg diff` to check basic driver functionality fn1 = pjoin(filespath, 'foo--1.ipynb') fn2 = pjoin(filespath, 'foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = ['/mock/path/hg-nbdiffdriver', '--no-color', '-O', fn1, fn2] with mock.patch('sys.argv', mock_argv): r = hgd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_source_only.format(fn1, fn2, t1, t2)
def test_hg_diff_driver_flags(filespath, capsys, nocolor, needs_hg, reset_diff_targets): # Simulate a call from `hg diff` to check basic driver functionality fn1 = pjoin(filespath, 'foo--1.ipynb') fn2 = pjoin(filespath, 'foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/hg-nbdiffdriver', '-s', fn1, fn2] with mock.patch('sys.argv', mock_argv): r = hgd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_source_only.format(fn1, fn2, t1, t2)