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)
def test_git_diff_driver_no_filter_without_flag(git_repo, filespath, capsys): _config_filter_driver('add_helper', capsys) fn1 = pjoin(git_repo, 'diff.ipynb') fn2 = pjoin(filespath, 'src-and-output--1.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', '--no-color', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644' ] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_no_filter.format(fn1, fn2, t1, t2)
def test_git_diff_driver(filespath, capsys, nocolor, needs_git): # Simulate a call from `git 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/git-nbdiffdriver', 'diff', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644' ] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_output.format(fn1, fn2, t1, t2)
def test_git_diff_driver_no_filter_without_flag(git_repo, filespath, capsys, nocolor): _config_filter_driver('add_helper', capsys) fn1 = pjoin(git_repo, 'diff.ipynb') fn2 = pjoin(filespath, 'src-and-output--1.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644'] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_no_filter.format(fn1, fn2, t1, t2)
def test_git_diff_driver_ignore_flags(filespath, capsys, nocolor, needs_git, reset_diff_targets): # Simulate a call from `git 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/git-nbdiffdriver', 'diff', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644'] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_source_only.format(fn1, fn2, t1, t2)
def test_git_diff_driver(capsys, nocolor): # Simulate a call from `git diff` to check basic driver functionality test_dir = os.path.abspath(os.path.dirname(__file__)) fn1 = pjoin(test_dir, 'files/foo--1.ipynb') fn2 = pjoin(test_dir, 'files/foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644'] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_output.format(fn1, fn2, t1, t2)