From 92a97480edcc0f0de787a752bf90feed0445dd39 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 9 Oct 2009 11:57:48 +0200 Subject: Blob|Tree: renamed 'name' member to 'path', updated tests and changelog as it would make existing code incompatible in some places --- test/git/test_commit.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index d6bd6120..fb376b02 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -37,8 +37,8 @@ class TestCommit(object): assert_equal(15, len(diffs)) - assert_equal('.gitignore', diffs[0].a_blob.name) - assert_equal('.gitignore', diffs[0].b_blob.name) + assert_equal('.gitignore', diffs[0].a_blob.path) + assert_equal('.gitignore', diffs[0].b_blob.path) assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) assert_equal('100644', diffs[0].b_blob.mode) @@ -46,7 +46,7 @@ class TestCommit(object): assert_equal(False, diffs[0].deleted_file) assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name) + assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) assert_equal(None, diffs[5].a_blob) assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) assert_equal( None, diffs[5].a_mode ) @@ -89,7 +89,7 @@ class TestCommit(object): diffs = Commit.diff(self.repo, '59ddc32', ['lib']) assert_equal(1, len(diffs)) - assert_equal('lib/grit/diff.rb', diffs[0].a_blob.name) + assert_equal('lib/grit/diff.rb', diffs[0].a_blob.path) assert_true(git.called) assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True})) @@ -101,7 +101,7 @@ class TestCommit(object): diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib']) assert_equal(1, len(diffs)) - assert_equal('lib/grit/commit.rb', diffs[0].a_blob.name) + assert_equal('lib/grit/commit.rb', diffs[0].a_blob.path) assert_true(git.called) assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True})) @@ -115,8 +115,8 @@ class TestCommit(object): assert_equal(15, len(diffs)) - assert_equal('.gitignore', diffs[0].a_blob.name) - assert_equal('.gitignore', diffs[0].b_blob.name) + assert_equal('.gitignore', diffs[0].a_blob.path) + assert_equal('.gitignore', diffs[0].b_blob.path) assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) assert_equal('100644', diffs[0].b_blob.mode) @@ -124,7 +124,7 @@ class TestCommit(object): assert_equal(False, diffs[0].deleted_file) assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name) + assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) assert_equal(None, diffs[5].a_blob) assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) assert_equal(True, diffs[5].new_file) @@ -145,7 +145,7 @@ class TestCommit(object): assert_equal(10, len(diffs)) - assert_equal('History.txt', diffs[0].b_blob.name) + assert_equal('History.txt', diffs[0].b_blob.path) assert_equal(None, diffs[0].a_blob) assert_equal('100644', diffs[0].b_blob.mode) assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id) @@ -153,7 +153,7 @@ class TestCommit(object): assert_equal(False, diffs[0].deleted_file) assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff) - assert_equal('lib/grit.rb', diffs[5].b_blob.name) + assert_equal('lib/grit.rb', diffs[5].b_blob.path) assert_equal(None, diffs[5].a_blob) assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id) assert_equal(True, diffs[5].new_file) -- cgit v1.2.1 From 9374a916588d9fe7169937ba262c86ad710cfa74 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 16:49:05 +0200 Subject: converted all spaces to tabs ( 4 spaces = 1 tab ) just to allow me and my editor to work with the files properly. Can convert it back for releaes --- test/git/test_commit.py | 394 ++++++++++++++++++++++++------------------------ 1 file changed, 197 insertions(+), 197 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index fb376b02..e92c13dd 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -8,241 +8,241 @@ from test.testlib import * from git import * class TestCommit(object): - def setup(self): - self.repo = Repo(GIT_REPO) + def setup(self): + self.repo = Repo(GIT_REPO) - @patch_object(Git, '_call_process') - def test_bake(self, git): - git.return_value = fixture('rev_list_single') + @patch_object(Git, '_call_process') + def test_bake(self, git): + git.return_value = fixture('rev_list_single') - commit = Commit(self.repo, **{'id': '4c8124ffcf4039d292442eeccabdeca5af5c5017'}) - commit.author # bake + commit = Commit(self.repo, **{'id': '4c8124ffcf4039d292442eeccabdeca5af5c5017'}) + commit.author # bake - assert_equal("Tom Preston-Werner", commit.author.name) - assert_equal("tom@mojombo.com", commit.author.email) + assert_equal("Tom Preston-Werner", commit.author.name) + assert_equal("tom@mojombo.com", commit.author.email) - assert_true(git.called) - assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1})) + assert_true(git.called) + assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1})) - @patch_object(Git, '_call_process') - def test_id_abbrev(self, git): - git.return_value = fixture('rev_list_commit_idabbrev') - assert_equal('80f136f', self.repo.commit('80f136f500dfdb8c3e8abf4ae716f875f0a1b57f').id_abbrev) + @patch_object(Git, '_call_process') + def test_id_abbrev(self, git): + git.return_value = fixture('rev_list_commit_idabbrev') + assert_equal('80f136f', self.repo.commit('80f136f500dfdb8c3e8abf4ae716f875f0a1b57f').id_abbrev) - @patch_object(Git, '_call_process') - def test_diff(self, git): - git.return_value = fixture('diff_p') + @patch_object(Git, '_call_process') + def test_diff(self, git): + git.return_value = fixture('diff_p') - diffs = Commit.diff(self.repo, 'master') + diffs = Commit.diff(self.repo, 'master') - assert_equal(15, len(diffs)) + assert_equal(15, len(diffs)) - assert_equal('.gitignore', diffs[0].a_blob.path) - assert_equal('.gitignore', diffs[0].b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal(False, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) + assert_equal('.gitignore', diffs[0].a_blob.path) + assert_equal('.gitignore', diffs[0].b_blob.path) + assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) + assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) + assert_equal('100644', diffs[0].b_blob.mode) + assert_equal(False, diffs[0].new_file) + assert_equal(False, diffs[0].deleted_file) + assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) - assert_equal( None, diffs[5].a_mode ) - assert_equal(True, diffs[5].new_file) + assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) + assert_equal(None, diffs[5].a_blob) + assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) + assert_equal( None, diffs[5].a_mode ) + assert_equal(True, diffs[5].new_file) - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', 'master'), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', 'master'), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diff_with_rename(self, git): - git.return_value = fixture('diff_rename') + @patch_object(Git, '_call_process') + def test_diff_with_rename(self, git): + git.return_value = fixture('diff_rename') - diffs = Commit.diff(self.repo, 'rename') + diffs = Commit.diff(self.repo, 'rename') - assert_equal(1, len(diffs)) + assert_equal(1, len(diffs)) - diff = diffs[0] - assert_true(diff.renamed) - assert_equal(diff.rename_from, 'AUTHORS') - assert_equal(diff.rename_to, 'CONTRIBUTORS') + diff = diffs[0] + assert_true(diff.renamed) + assert_equal(diff.rename_from, 'AUTHORS') + assert_equal(diff.rename_to, 'CONTRIBUTORS') - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', 'rename'), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', 'rename'), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diff_with_two_commits(self, git): - git.return_value = fixture('diff_2') + @patch_object(Git, '_call_process') + def test_diff_with_two_commits(self, git): + git.return_value = fixture('diff_2') - diffs = Commit.diff(self.repo, '59ddc32', '13d27d5') + diffs = Commit.diff(self.repo, '59ddc32', '13d27d5') - assert_equal(3, len(diffs)) + assert_equal(3, len(diffs)) - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5'), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5'), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diff_with_files(self, git): - git.return_value = fixture('diff_f') + @patch_object(Git, '_call_process') + def test_diff_with_files(self, git): + git.return_value = fixture('diff_f') - diffs = Commit.diff(self.repo, '59ddc32', ['lib']) + diffs = Commit.diff(self.repo, '59ddc32', ['lib']) - assert_equal(1, len(diffs)) - assert_equal('lib/grit/diff.rb', diffs[0].a_blob.path) + assert_equal(1, len(diffs)) + assert_equal('lib/grit/diff.rb', diffs[0].a_blob.path) - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diff_with_two_commits_and_files(self, git): - git.return_value = fixture('diff_2f') + @patch_object(Git, '_call_process') + def test_diff_with_two_commits_and_files(self, git): + git.return_value = fixture('diff_2f') - diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib']) + diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib']) - assert_equal(1, len(diffs)) - assert_equal('lib/grit/commit.rb', diffs[0].a_blob.path) + assert_equal(1, len(diffs)) + assert_equal('lib/grit/commit.rb', diffs[0].a_blob.path) - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diffs(self, git): - git.return_value = fixture('diff_p') + @patch_object(Git, '_call_process') + def test_diffs(self, git): + git.return_value = fixture('diff_p') - commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769', parents=['038af8c329ef7c1bae4568b98bd5c58510465493']) - diffs = commit.diffs + commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769', parents=['038af8c329ef7c1bae4568b98bd5c58510465493']) + diffs = commit.diffs - assert_equal(15, len(diffs)) + assert_equal(15, len(diffs)) - assert_equal('.gitignore', diffs[0].a_blob.path) - assert_equal('.gitignore', diffs[0].b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal(False, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) + assert_equal('.gitignore', diffs[0].a_blob.path) + assert_equal('.gitignore', diffs[0].b_blob.path) + assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) + assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) + assert_equal('100644', diffs[0].b_blob.mode) + assert_equal(False, diffs[0].new_file) + assert_equal(False, diffs[0].deleted_file) + assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) - assert_equal(True, diffs[5].new_file) + assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) + assert_equal(None, diffs[5].a_blob) + assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) + assert_equal(True, diffs[5].new_file) - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', - '038af8c329ef7c1bae4568b98bd5c58510465493', - '91169e1f5fa4de2eaea3f176461f5dc784796769', - ), {'full_index': True})) + assert_true(git.called) + assert_equal(git.call_args, (('diff', '-M', + '038af8c329ef7c1bae4568b98bd5c58510465493', + '91169e1f5fa4de2eaea3f176461f5dc784796769', + ), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diffs_on_initial_import(self, git): - git.return_value = fixture('diff_i') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - commit.__bake_it__() - diffs = commit.diffs + @patch_object(Git, '_call_process') + def test_diffs_on_initial_import(self, git): + git.return_value = fixture('diff_i') + + commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') + commit.__bake_it__() + diffs = commit.diffs - assert_equal(10, len(diffs)) + assert_equal(10, len(diffs)) - assert_equal('History.txt', diffs[0].b_blob.path) - assert_equal(None, diffs[0].a_blob) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id) - assert_equal(True, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff) + assert_equal('History.txt', diffs[0].b_blob.path) + assert_equal(None, diffs[0].a_blob) + assert_equal('100644', diffs[0].b_blob.mode) + assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id) + assert_equal(True, diffs[0].new_file) + assert_equal(False, diffs[0].deleted_file) + assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff) - assert_equal('lib/grit.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id) - assert_equal(True, diffs[5].new_file) + assert_equal('lib/grit.rb', diffs[5].b_blob.path) + assert_equal(None, diffs[5].a_blob) + assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id) + assert_equal(True, diffs[5].new_file) - assert_true(git.called) - assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) + assert_true(git.called) + assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) - @patch_object(Git, '_call_process') - def test_diffs_on_initial_import_with_empty_commit(self, git): - git.return_value = fixture('show_empty_commit') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - diffs = commit.diffs + @patch_object(Git, '_call_process') + def test_diffs_on_initial_import_with_empty_commit(self, git): + git.return_value = fixture('show_empty_commit') + + commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') + diffs = commit.diffs - assert_equal([], diffs) - - assert_true(git.called) - assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) - - @patch_object(Git, '_call_process') - def test_diffs_with_mode_only_change(self, git): - git.return_value = fixture('diff_mode_only') - - commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769') - commit.__bake_it__() - diffs = commit.diffs - - # in case of mode-only changes, there is no blob - assert_equal(23, len(diffs)) - assert_equal(None, diffs[0].a_blob) - assert_equal(None, diffs[0].b_blob) - assert_equal('100644', diffs[0].a_mode) - assert_equal('100755', diffs[0].b_mode) - - assert_true(git.called) - assert_equal(git.call_args, (('show', '91169e1f5fa4de2eaea3f176461f5dc784796769', '-M'), {'full_index': True, 'pretty': 'raw'})) - - @patch_object(Git, '_call_process') - def test_stats(self, git): - git.return_value = fixture('diff_tree_numstat_root') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - commit.__bake_it__() - stats = commit.stats - - keys = stats.files.keys() - keys.sort() - assert_equal(["a.txt", "b.txt"], keys) - - assert_true(git.called) - assert_equal(git.call_args, (('diff_tree', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '--'), {'numstat': True, 'root': True })) - - @patch_object(Git, '_call_process') - def test_rev_list_bisect_all(self, git): - """ - 'git rev-list --bisect-all' returns additional information - in the commit header. This test ensures that we properly parse it. - """ - - git.return_value = fixture('rev_list_bisect_all') - - revs = self.repo.git.rev_list('HEAD', - pretty='raw', - first_parent=True, - bisect_all=True) - assert_true(git.called) - - commits = Commit.list_from_string(self.repo, revs) - expected_ids = ( - 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', - '33ebe7acec14b25c5f84f35a664803fcab2f7781', - 'a6604a00a652e754cb8b6b0b9f194f839fc38d7c', - '8df638c22c75ddc9a43ecdde90c0c9939f5009e7', - 'c231551328faa864848bde6ff8127f59c9566e90', - ) - for sha1, commit in zip(expected_ids, commits): - assert_equal(sha1, commit.id) - - def test_str(self): - commit = Commit(self.repo, id='abc') - assert_equal ("abc", str(commit)) - - def test_repr(self): - commit = Commit(self.repo, id='abc') - assert_equal('', repr(commit)) - - def test_equality(self): - commit1 = Commit(self.repo, id='abc') - commit2 = Commit(self.repo, id='abc') - commit3 = Commit(self.repo, id='zyx') - assert_equal(commit1, commit2) - assert_not_equal(commit2, commit3) + assert_equal([], diffs) + + assert_true(git.called) + assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) + + @patch_object(Git, '_call_process') + def test_diffs_with_mode_only_change(self, git): + git.return_value = fixture('diff_mode_only') + + commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769') + commit.__bake_it__() + diffs = commit.diffs + + # in case of mode-only changes, there is no blob + assert_equal(23, len(diffs)) + assert_equal(None, diffs[0].a_blob) + assert_equal(None, diffs[0].b_blob) + assert_equal('100644', diffs[0].a_mode) + assert_equal('100755', diffs[0].b_mode) + + assert_true(git.called) + assert_equal(git.call_args, (('show', '91169e1f5fa4de2eaea3f176461f5dc784796769', '-M'), {'full_index': True, 'pretty': 'raw'})) + + @patch_object(Git, '_call_process') + def test_stats(self, git): + git.return_value = fixture('diff_tree_numstat_root') + + commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') + commit.__bake_it__() + stats = commit.stats + + keys = stats.files.keys() + keys.sort() + assert_equal(["a.txt", "b.txt"], keys) + + assert_true(git.called) + assert_equal(git.call_args, (('diff_tree', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '--'), {'numstat': True, 'root': True })) + + @patch_object(Git, '_call_process') + def test_rev_list_bisect_all(self, git): + """ + 'git rev-list --bisect-all' returns additional information + in the commit header. This test ensures that we properly parse it. + """ + + git.return_value = fixture('rev_list_bisect_all') + + revs = self.repo.git.rev_list('HEAD', + pretty='raw', + first_parent=True, + bisect_all=True) + assert_true(git.called) + + commits = Commit.list_from_string(self.repo, revs) + expected_ids = ( + 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', + '33ebe7acec14b25c5f84f35a664803fcab2f7781', + 'a6604a00a652e754cb8b6b0b9f194f839fc38d7c', + '8df638c22c75ddc9a43ecdde90c0c9939f5009e7', + 'c231551328faa864848bde6ff8127f59c9566e90', + ) + for sha1, commit in zip(expected_ids, commits): + assert_equal(sha1, commit.id) + + def test_str(self): + commit = Commit(self.repo, id='abc') + assert_equal ("abc", str(commit)) + + def test_repr(self): + commit = Commit(self.repo, id='abc') + assert_equal('', repr(commit)) + + def test_equality(self): + commit1 = Commit(self.repo, id='abc') + commit2 = Commit(self.repo, id='abc') + commit3 = Commit(self.repo, id='zyx') + assert_equal(commit1, commit2) + assert_not_equal(commit2, commit3) -- cgit v1.2.1 From 15b9129ec639112e94ea96b6a395ad9b149515d1 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 19:07:03 +0200 Subject: lazymixin system now supports per-attribute baking, it is up to the class whether it bakes more. This also leads to more efficient use of memory as values are only cached and set when required - the baking system does not require an own tracking variable anymore, and values are only to be cached once - then python will natively find the cache without involving any additional overhead. This works by using __getattr__ instead of __get_attribute__ which would always be called --- test/git/test_commit.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index e92c13dd..341d72e2 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -140,7 +140,6 @@ class TestCommit(object): git.return_value = fixture('diff_i') commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - commit.__bake_it__() diffs = commit.diffs assert_equal(10, len(diffs)) @@ -178,7 +177,6 @@ class TestCommit(object): git.return_value = fixture('diff_mode_only') commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769') - commit.__bake_it__() diffs = commit.diffs # in case of mode-only changes, there is no blob @@ -196,7 +194,6 @@ class TestCommit(object): git.return_value = fixture('diff_tree_numstat_root') commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - commit.__bake_it__() stats = commit.stats keys = stats.files.keys() -- cgit v1.2.1 From 708b8dda8e7b87841a5f39c60b799c514e75a9c7 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 21:17:59 +0200 Subject: commit: fixed failing commit tests as the mocked git command would always return the same thing which does not work anymore - re-implemented it in a more dynamic manner, but in the end tests will have to be revised anyway Added slots to Diff and Stats type respectively --- test/git/test_commit.py | 82 ++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 46 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 341d72e2..79768c3f 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -135,30 +135,21 @@ class TestCommit(object): '91169e1f5fa4de2eaea3f176461f5dc784796769', ), {'full_index': True})) - @patch_object(Git, '_call_process') - def test_diffs_on_initial_import(self, git): - git.return_value = fixture('diff_i') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') - diffs = commit.diffs - - assert_equal(10, len(diffs)) - - assert_equal('History.txt', diffs[0].b_blob.path) - assert_equal(None, diffs[0].a_blob) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id) - assert_equal(True, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff) - - assert_equal('lib/grit.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id) - assert_equal(True, diffs[5].new_file) - - assert_true(git.called) - assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) + def test_diffs_on_initial_import(self): + commit = Commit(self.repo, '33ebe7acec14b25c5f84f35a664803fcab2f7781') + + for diff in commit.diffs: + assert isinstance(diff, Diff) + assert isinstance(diff.a_blob, Blob) or isinstance(diff.b_blob, Blob) + assert isinstance(diff.a_mode, int) and isinstance(diff.b_mode, int) + assert diff.diff + if diff.renamed: + assert diff.rename_from and diff.rename_to and diff.rename_from != diff.rename_to + if diff.a_blob is None: + assert diff.new_file and isinstance(diff.new_file, bool) + if diff.b_blob is None: + assert diff.deleted_file and isinstance(diff.deleted_file, bool) + # END for each diff in initial import commit @patch_object(Git, '_call_process') def test_diffs_on_initial_import_with_empty_commit(self, git): @@ -172,37 +163,36 @@ class TestCommit(object): assert_true(git.called) assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) - @patch_object(Git, '_call_process') - def test_diffs_with_mode_only_change(self, git): - git.return_value = fixture('diff_mode_only') - - commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769') + def test_diffs_with_mode_only_change(self): + commit = Commit(self.repo, id='ccde80b7a3037a004a7807a6b79916ce2a1e9729') diffs = commit.diffs # in case of mode-only changes, there is no blob - assert_equal(23, len(diffs)) + assert_equal(1, len(diffs)) assert_equal(None, diffs[0].a_blob) assert_equal(None, diffs[0].b_blob) assert_equal('100644', diffs[0].a_mode) assert_equal('100755', diffs[0].b_mode) - assert_true(git.called) - assert_equal(git.call_args, (('show', '91169e1f5fa4de2eaea3f176461f5dc784796769', '-M'), {'full_index': True, 'pretty': 'raw'})) - - @patch_object(Git, '_call_process') - def test_stats(self, git): - git.return_value = fixture('diff_tree_numstat_root') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') + def test_stats(self): + commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats - - keys = stats.files.keys() - keys.sort() - assert_equal(["a.txt", "b.txt"], keys) - - assert_true(git.called) - assert_equal(git.call_args, (('diff_tree', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '--'), {'numstat': True, 'root': True })) - + + def check_entries(d): + assert isinstance(d, dict) + for key in ("insertions", "deletions", "lines"): + assert key in d + # END assertion helper + assert stats.files + assert stats.total + + check_entries(stats.total) + assert "files" in stats.total + + for filepath, d in stats.files.items(): + check_entries(d) + # END for each stated file + @patch_object(Git, '_call_process') def test_rev_list_bisect_all(self, git): """ -- cgit v1.2.1 From b01824b1aecf8aadae4501e22feb45c20fb26bce Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 22:22:28 +0200 Subject: Fixed remaining tests to deal with the changes mode is now generally an int compatible to the stat module --- test/git/test_commit.py | 74 ++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 79768c3f..ab1801ee 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -36,21 +36,25 @@ class TestCommit(object): diffs = Commit.diff(self.repo, 'master') assert_equal(15, len(diffs)) + + diff = diffs[0] + assert_equal('.gitignore', diff.a_blob.path) + assert_equal('.gitignore', diff.b_blob.path) + assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id) + assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id) + + assert_mode_644(diff.b_blob.mode) + + assert_equal(False, diff.new_file) + assert_equal(False, diff.deleted_file) + assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff) - assert_equal('.gitignore', diffs[0].a_blob.path) - assert_equal('.gitignore', diffs[0].b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal(False, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) - assert_equal( None, diffs[5].a_mode ) - assert_equal(True, diffs[5].new_file) + diff = diffs[5] + assert_equal('lib/grit/actor.rb', diff.b_blob.path) + assert_equal(None, diff.a_blob) + assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id) + assert_equal( None, diff.a_mode ) + assert_equal(True, diff.new_file) assert_true(git.called) assert_equal(git.call_args, (('diff', '-M', 'master'), {'full_index': True})) @@ -115,19 +119,21 @@ class TestCommit(object): assert_equal(15, len(diffs)) - assert_equal('.gitignore', diffs[0].a_blob.path) - assert_equal('.gitignore', diffs[0].b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id) - assert_equal('100644', diffs[0].b_blob.mode) - assert_equal(False, diffs[0].new_file) - assert_equal(False, diffs[0].deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff) - - assert_equal('lib/grit/actor.rb', diffs[5].b_blob.path) - assert_equal(None, diffs[5].a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id) - assert_equal(True, diffs[5].new_file) + diff = diffs[0] + assert_equal('.gitignore', diff.a_blob.path) + assert_equal('.gitignore', diff.b_blob.path) + assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id) + assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id) + assert_mode_644(diff.b_blob.mode) + assert_equal(False, diff.new_file) + assert_equal(False, diff.deleted_file) + assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff) + + diff = diffs[5] + assert_equal('lib/grit/actor.rb', diff.b_blob.path) + assert_equal(None, diff.a_blob) + assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id) + assert_equal(True, diff.new_file) assert_true(git.called) assert_equal(git.call_args, (('diff', '-M', @@ -141,8 +147,14 @@ class TestCommit(object): for diff in commit.diffs: assert isinstance(diff, Diff) assert isinstance(diff.a_blob, Blob) or isinstance(diff.b_blob, Blob) - assert isinstance(diff.a_mode, int) and isinstance(diff.b_mode, int) - assert diff.diff + + if diff.a_mode is not None: + assert isinstance(diff.a_mode, int) + if diff.b_mode is not None: + isinstance(diff.b_mode, int) + + assert diff.diff is not None # can be empty + if diff.renamed: assert diff.rename_from and diff.rename_to and diff.rename_from != diff.rename_to if diff.a_blob is None: @@ -171,8 +183,8 @@ class TestCommit(object): assert_equal(1, len(diffs)) assert_equal(None, diffs[0].a_blob) assert_equal(None, diffs[0].b_blob) - assert_equal('100644', diffs[0].a_mode) - assert_equal('100755', diffs[0].b_mode) + assert_mode_644(diffs[0].a_mode) + assert_mode_755(diffs[0].b_mode) def test_stats(self): commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') -- cgit v1.2.1 From c68459a17ff59043d29c90020fffe651b2164e6a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 22:50:07 +0200 Subject: Added remaining tests for new base classes and removed some methods whose existance was doubtful or unsafe --- test/git/test_commit.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index ab1801ee..71dad562 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -24,10 +24,6 @@ class TestCommit(object): assert_true(git.called) assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1})) - @patch_object(Git, '_call_process') - def test_id_abbrev(self, git): - git.return_value = fixture('rev_list_commit_idabbrev') - assert_equal('80f136f', self.repo.commit('80f136f500dfdb8c3e8abf4ae716f875f0a1b57f').id_abbrev) @patch_object(Git, '_call_process') def test_diff(self, git): -- cgit v1.2.1 From 637eadce54ca8bbe536bcf7c570c025e28e47129 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Oct 2009 14:56:47 +0200 Subject: renamed from_string and list_from_string to _from_string and _list_from_string to indicate their new status as private method, adjusted all callers respectively --- test/git/test_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 71dad562..fa49821d 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -216,7 +216,7 @@ class TestCommit(object): bisect_all=True) assert_true(git.called) - commits = Commit.list_from_string(self.repo, revs) + commits = Commit._list_from_string(self.repo, revs) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', -- cgit v1.2.1 From 6acec357c7609fdd2cb0f5fdb1d2756726c7fe98 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 13 Oct 2009 21:26:19 +0200 Subject: renamed find_all to list_all, changed commit to use iterable interface in preparation for command changes --- test/git/test_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index fa49821d..0fb4bceb 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -216,7 +216,7 @@ class TestCommit(object): bisect_all=True) assert_true(git.called) - commits = Commit._list_from_string(self.repo, revs) + commits = Commit._iter_from_stream(self.repo, iter(revs.splitlines(False))) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', -- cgit v1.2.1 From ead94f267065bb55303f79a0a6df477810b3c68d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 14:33:51 +0200 Subject: cmd: added option to return the process directly, allowing to read the output directly from the output stream commit: now reads commit information directly from the output stream of the process by implementing its iterator method repo: removed log method as it was redundant ( equal to the commits method ) --- test/git/test_commit.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 0fb4bceb..00af6b52 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -11,18 +11,13 @@ class TestCommit(object): def setup(self): self.repo = Repo(GIT_REPO) - @patch_object(Git, '_call_process') - def test_bake(self, git): - git.return_value = fixture('rev_list_single') + def test_bake(self): - commit = Commit(self.repo, **{'id': '4c8124ffcf4039d292442eeccabdeca5af5c5017'}) + commit = Commit(self.repo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) commit.author # bake - assert_equal("Tom Preston-Werner", commit.author.name) - assert_equal("tom@mojombo.com", commit.author.email) - - assert_true(git.called) - assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1})) + assert_equal("Sebastian Thiel", commit.author.name) + assert_equal("byronimo@gmail.com", commit.author.email) @patch_object(Git, '_call_process') @@ -159,17 +154,10 @@ class TestCommit(object): assert diff.deleted_file and isinstance(diff.deleted_file, bool) # END for each diff in initial import commit - @patch_object(Git, '_call_process') - def test_diffs_on_initial_import_with_empty_commit(self, git): - git.return_value = fixture('show_empty_commit') - - commit = Commit(self.repo, id='634396b2f541a9f2d58b00be1a07f0c358b999b3') + def test_diffs_on_initial_import_without_parents(self): + commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') diffs = commit.diffs - - assert_equal([], diffs) - - assert_true(git.called) - assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'})) + assert diffs def test_diffs_with_mode_only_change(self): commit = Commit(self.repo, id='ccde80b7a3037a004a7807a6b79916ce2a1e9729') @@ -216,7 +204,7 @@ class TestCommit(object): bisect_all=True) assert_true(git.called) - commits = Commit._iter_from_stream(self.repo, iter(revs.splitlines(False))) + commits = Commit._iter_from_process(self.repo, ListProcessAdapter(revs)) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', -- cgit v1.2.1 From 6eeae8b24135b4de05f6d725b009c287577f053d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 17:24:15 +0200 Subject: test: Added time-consuming test which could also be a benchmark in fact - currently it cause hundreds of command invocations which is slow Fixed issue with trees not properly initialized with their default mode _set_cache_: some objects checked whether the attribute was within their __slots__ although it should have been accessed through its class --- test/git/test_commit.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 00af6b52..fd8fc51e 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -229,3 +229,18 @@ class TestCommit(object): commit3 = Commit(self.repo, id='zyx') assert_equal(commit1, commit2) assert_not_equal(commit2, commit3) + + def test_iteration(self): + root = self.repo.tree() + head = self.repo.active_branch + num_objs = 0 + + # find the first commit containing the given path - always do a full + # iteration ( restricted to the path in question ), but in fact it should + # return quite a lot of commits, we just take one and hence abort the operation + for obj in root.traverse(): + num_objs += 1 + commit = Commit.iter_items( self.repo, head, obj.path ).next() + assert obj in commit.tree.traverse() + # END for each object + -- cgit v1.2.1 From 6745f4542cfb74bbf3b933dba7a59ef2f54a4380 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 19:34:45 +0200 Subject: test_blob: removed many redundant tests that would fail now as the mock cannot handle the complexity of the command backend All objects but Tree now use the persistent command to read their object information - Trees get binary data and would need their own pretty-printing or they need to parse the data themselves which is my favorite --- test/git/test_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index fd8fc51e..c050fd11 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -204,7 +204,7 @@ class TestCommit(object): bisect_all=True) assert_true(git.called) - commits = Commit._iter_from_process(self.repo, ListProcessAdapter(revs)) + commits = Commit._iter_from_process_or_stream(self.repo, ListProcessAdapter(revs)) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', -- cgit v1.2.1 From 7cdfaceebe916c91acdf8de3f9506989bc70ad65 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 23:41:48 +0200 Subject: Removed plenty of mocked tree tests as they cannot work anymore with persistent commands that require stdin AND binary data - not even an adapter would help here. These tests will have to be replaced. test_commit: Improved efficiency of traversal test --- test/git/test_commit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index c050fd11..1966d198 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -233,14 +233,16 @@ class TestCommit(object): def test_iteration(self): root = self.repo.tree() head = self.repo.active_branch + head_commit = self.repo.active_branch.object num_objs = 0 # find the first commit containing the given path - always do a full # iteration ( restricted to the path in question ), but in fact it should # return quite a lot of commits, we just take one and hence abort the operation + for obj in root.traverse(): num_objs += 1 - commit = Commit.iter_items( self.repo, head, obj.path ).next() - assert obj in commit.tree.traverse() + del( head_commit.tree ) # force it to clear the cache, just to make it harder + assert obj in head_commit.tree.traverse() # END for each object -- cgit v1.2.1 From 1a4bfd979e5d4ea0d0457e552202eb2effc36cac Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 15 Oct 2009 00:06:08 +0200 Subject: test_performance: module containing benchmarks to get an idea of the achieved throughput repo.commits: max_count is None by default moved benchmark-like test from test_commit to test_performance --- test/git/test_commit.py | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 1966d198..a95fb675 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -230,19 +230,3 @@ class TestCommit(object): assert_equal(commit1, commit2) assert_not_equal(commit2, commit3) - def test_iteration(self): - root = self.repo.tree() - head = self.repo.active_branch - head_commit = self.repo.active_branch.object - num_objs = 0 - - # find the first commit containing the given path - always do a full - # iteration ( restricted to the path in question ), but in fact it should - # return quite a lot of commits, we just take one and hence abort the operation - - for obj in root.traverse(): - num_objs += 1 - del( head_commit.tree ) # force it to clear the cache, just to make it harder - assert obj in head_commit.tree.traverse() - # END for each object - -- cgit v1.2.1