Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_modified_lines_new_addition(self):
self.assertEqual(
None,
git.modified_lines('/home/user/repo/foo/bar.txt', 'A '))
def test_modified_lines(self):
output = os.linesep.join([
'baz',
'0000000000000000000000000000000000000000 2 2 4',
'foo',
'0000000000000000000000000000000000000000 5 5',
'bar']).encode('utf-8')
with mock.patch('subprocess.check_output',
return_value=output) as check_output:
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
expected_calls = [mock.call(
['git', 'blame', '--porcelain',
'/home/user/repo/foo/bar.txt'])] * 3
self.assertEqual(expected_calls, check_output.call_args_list)
def test_modified_lines(self):
output = os.linesep.join([
'baz',
'0000000000000000000000000000000000000000 2 2 4',
'foo',
'0000000000000000000000000000000000000000 5 5',
'bar']).encode('utf-8')
with mock.patch('subprocess.check_output',
return_value=output) as check_output:
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
expected_calls = [mock.call(
['git', 'blame', '--porcelain',
'/home/user/repo/foo/bar.txt'])] * 3
self.assertEqual(expected_calls, check_output.call_args_list)
'baz',
'0000000000000000000000000000000000000000 2 2 4',
'foo',
'0000000000000000000000000000000000000000 5 5',
'bar']).encode('utf-8')
with mock.patch('subprocess.check_output',
return_value=output) as check_output:
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
self.assertEqual(
[2, 5],
list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
expected_calls = [mock.call(
['git', 'blame', '--porcelain',
'/home/user/repo/foo/bar.txt'])] * 3
self.assertEqual(expected_calls, check_output.call_args_list)
return_value=output) as check_output:
self.assertEqual(
[2, 5],
list(git.modified_lines(
'/home/user/repo/foo/bar.txt',
' M',
commit='0123456789abcdef31410123456789abcdef3141')))
self.assertEqual(
[2, 5],
list(git.modified_lines(
'/home/user/repo/foo/bar.txt',
'M ',
commit='0123456789abcdef31410123456789abcdef3141')))
self.assertEqual(
[2, 5],
list(git.modified_lines(
'/home/user/repo/foo/bar.txt',
'MM',
commit='0123456789abcdef31410123456789abcdef3141')))
expected_calls = [mock.call(
['git', 'blame', '--porcelain',
'/home/user/repo/foo/bar.txt'])] * 3
self.assertEqual(expected_calls, check_output.call_args_list)