| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,26 +7,24 @@ | |||
| 7 | 7 | from test.testlib import * | |
| 8 | 8 | from git import * | |
| 9 | 9 | ||
| 10 | - class TestBlob(object): | ||
| 11 | - def setup(self): | ||
| 12 | - self.repo = Repo(GIT_REPO) | ||
| 10 | + class TestBlob(TestBase): | ||
| 13 | 11 | ||
| 14 | 12 | def test_should_cache_data(self): | |
| 15 | 13 | bid = 'a802c139d4767c89dcad79d836d05f7004d39aac' | |
| 16 | - blob = Blob(self.repo, bid) | ||
| 14 | + blob = Blob(self.rorepo, bid) | ||
| 17 | 15 | blob.data | |
| 18 | 16 | assert blob.data | |
| 19 | 17 | blob.size | |
| 20 | 18 | blob.size | |
| 21 | 19 | ||
| 22 | 20 | def test_mime_type_should_return_mime_type_for_known_types(self): | |
| 23 | - blob = Blob(self.repo, **{'id': 'abc', 'path': 'foo.png'}) | ||
| 21 | + blob = Blob(self.rorepo, **{'id': 'abc', 'path': 'foo.png'}) | ||
| 24 | 22 | assert_equal("image/png", blob.mime_type) | |
| 25 | 23 | ||
| 26 | 24 | def test_mime_type_should_return_text_plain_for_unknown_types(self): | |
| 27 | - blob = Blob(self.repo, **{'id': 'abc','path': 'something'}) | ||
| 25 | + blob = Blob(self.rorepo, **{'id': 'abc','path': 'something'}) | ||
| 28 | 26 | assert_equal("text/plain", blob.mime_type) | |
| 29 | 27 | ||
| 30 | 28 | def test_should_return_appropriate_representation(self): | |
| 31 | - blob = Blob(self.repo, **{'id': 'abc'}) | ||
| 29 | + blob = Blob(self.rorepo, **{'id': 'abc'}) | ||
| 32 | 30 | assert_equal('<git.Blob "abc">', repr(blob)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,21 +7,19 @@ | |||
| 7 | 7 | from test.testlib import * | |
| 8 | 8 | from git import * | |
| 9 | 9 | ||
| 10 | - class TestCommit(object): | ||
| 11 | - def setup(self): | ||
| 12 | - self.repo = Repo(GIT_REPO) | ||
| 10 | + class TestCommit(TestBase): | ||
| 13 | 11 | ||
| 14 | 12 | def test_bake(self): | |
| 15 | 13 | ||
| 16 | - commit = Commit(self.repo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) | ||
| 14 | + commit = Commit(self.rorepo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) | ||
| 17 | 15 | commit.author # bake | |
| 18 | 16 | ||
| 19 | 17 | assert_equal("Sebastian Thiel", commit.author.name) | |
| 20 | 18 | assert_equal("byronimo@gmail.com", commit.author.email) | |
| 21 | 19 | ||
| 22 | 20 | ||
| 23 | 21 | def test_stats(self): | |
| 24 | - commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') | ||
| 22 | + commit = Commit(self.rorepo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') | ||
| 25 | 23 | stats = commit.stats | |
| 26 | 24 | ||
| 27 | 25 | def check_entries(d): | |
@@ -48,13 +46,13 @@ def test_rev_list_bisect_all(self, git): | |||
| 48 | 46 | ||
| 49 | 47 | git.return_value = fixture('rev_list_bisect_all') | |
| 50 | 48 | ||
| 51 | - revs = self.repo.git.rev_list('HEAD', | ||
| 49 | + revs = self.rorepo.git.rev_list('HEAD', | ||
| 52 | 50 | pretty='raw', | |
| 53 | 51 | first_parent=True, | |
| 54 | 52 | bisect_all=True) | |
| 55 | 53 | assert_true(git.called) | |
| 56 | 54 | ||
| 57 | - commits = Commit._iter_from_process_or_stream(self.repo, ListProcessAdapter(revs)) | ||
| 55 | + commits = Commit._iter_from_process_or_stream(self.rorepo, ListProcessAdapter(revs)) | ||
| 58 | 56 | expected_ids = ( | |
| 59 | 57 | 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', | |
| 60 | 58 | '33ebe7acec14b25c5f84f35a664803fcab2f7781', | |
@@ -66,29 +64,29 @@ def test_rev_list_bisect_all(self, git): | |||
| 66 | 64 | assert_equal(sha1, commit.id) | |
| 67 | 65 | ||
| 68 | 66 | def test_count(self): | |
| 69 | - assert self.repo.tag('0.1.5').commit.count( ) == 141 | ||
| 67 | + assert self.rorepo.tag('0.1.5').commit.count( ) == 141 | ||
| 70 | 68 | ||
| 71 | 69 | def test_list(self): | |
| 72 | - assert isinstance(Commit.list_items(self.repo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) | ||
| 70 | + assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) | ||
| 73 | 71 | ||
| 74 | 72 | def test_str(self): | |
| 75 | - commit = Commit(self.repo, id='abc') | ||
| 73 | + commit = Commit(self.rorepo, id='abc') | ||
| 76 | 74 | assert_equal ("abc", str(commit)) | |
| 77 | 75 | ||
| 78 | 76 | def test_repr(self): | |
| 79 | - commit = Commit(self.repo, id='abc') | ||
| 77 | + commit = Commit(self.rorepo, id='abc') | ||
| 80 | 78 | assert_equal('<git.Commit "abc">', repr(commit)) | |
| 81 | 79 | ||
| 82 | 80 | def test_equality(self): | |
| 83 | - commit1 = Commit(self.repo, id='abc') | ||
| 84 | - commit2 = Commit(self.repo, id='abc') | ||
| 85 | - commit3 = Commit(self.repo, id='zyx') | ||
| 81 | + commit1 = Commit(self.rorepo, id='abc') | ||
| 82 | + commit2 = Commit(self.rorepo, id='abc') | ||
| 83 | + commit3 = Commit(self.rorepo, id='zyx') | ||
| 86 | 84 | assert_equal(commit1, commit2) | |
| 87 | 85 | assert_not_equal(commit2, commit3) | |
| 88 | 86 | ||
| 89 | 87 | def test_iter_parents(self): | |
| 90 | 88 | # should return all but ourselves, even if skip is defined | |
| 91 | - c = self.repo.commit('0.1.5') | ||
| 89 | + c = self.rorepo.commit('0.1.5') | ||
| 92 | 90 | for skip in (0, 1): | |
| 93 | 91 | piter = c.iter_parents(skip=skip) | |
| 94 | 92 | first_parent = piter.next() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,10 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | 12 | class TestBase(TestCase): | |
| 13 | 13 | ||
| 14 | - @classmethod | ||
| 15 | - def setUpAll(cls): | ||
| 16 | - cls.repo = Repo(GIT_REPO) | ||
| 17 | - | ||
| 18 | 14 | def _to_memcache(self, file_path): | |
| 19 | 15 | fp = open(file_path, "r") | |
| 20 | 16 | sio = StringIO.StringIO() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,19 +7,17 @@ | |||
| 7 | 7 | from test.testlib import * | |
| 8 | 8 | from git import * | |
| 9 | 9 | ||
| 10 | - class TestDiff(TestCase): | ||
| 11 | - def setUp(self): | ||
| 12 | - self.repo = Repo(GIT_REPO) | ||
| 13 | - | ||
| 10 | + class TestDiff(TestBase): | ||
| 11 | + | ||
| 14 | 12 | def test_list_from_string_new_mode(self): | |
| 15 | 13 | output = ListProcessAdapter(fixture('diff_new_mode')) | |
| 16 | - diffs = Diff._index_from_patch_format(self.repo, output.stdout) | ||
| 14 | + diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) | ||
| 17 | 15 | assert_equal(1, len(diffs)) | |
| 18 | 16 | assert_equal(10, len(diffs[0].diff.splitlines())) | |
| 19 | 17 | ||
| 20 | 18 | def test_diff_with_rename(self): | |
| 21 | 19 | output = ListProcessAdapter(fixture('diff_rename')) | |
| 22 | - diffs = Diff._index_from_patch_format(self.repo, output.stdout) | ||
| 20 | + diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) | ||
| 23 | 21 | ||
| 24 | 22 | assert_equal(1, len(diffs)) | |
| 25 | 23 | ||
@@ -37,13 +35,13 @@ def test_diff_patch_format(self): | |||
| 37 | 35 | ||
| 38 | 36 | for fixture_name in fixtures: | |
| 39 | 37 | diff_proc = ListProcessAdapter(fixture(fixture_name)) | |
| 40 | - diffs = Diff._index_from_patch_format(self.repo, diff_proc.stdout) | ||
| 38 | + diffs = Diff._index_from_patch_format(self.rorepo, diff_proc.stdout) | ||
| 41 | 39 | # END for each fixture | |
| 42 | 40 | ||
| 43 | 41 | def test_diff_interface(self): | |
| 44 | 42 | # test a few variations of the main diff routine | |
| 45 | 43 | assertion_map = dict() | |
| 46 | - for i, commit in enumerate(self.repo.iter_commits('0.1.6', max_count=10)): | ||
| 44 | + for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=10)): | ||
| 47 | 45 | diff_item = commit | |
| 48 | 46 | if i%2 == 0: | |
| 49 | 47 | diff_item = commit.tree | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,9 +8,11 @@ | |||
| 8 | 8 | from test.testlib import * | |
| 9 | 9 | from git import Git, GitCommandError | |
| 10 | 10 | ||
| 11 | - class TestGit(object): | ||
| 12 | - def setup(self): | ||
| 13 | - self.git = Git(GIT_REPO) | ||
| 11 | + class TestGit(TestCase): | ||
| 12 | + | ||
| 13 | + @classmethod | ||
| 14 | + def setUpAll(cls): | ||
| 15 | + cls.git = Git(GIT_REPO) | ||
| 14 | 16 | ||
| 15 | 17 | @patch_object(Git, 'execute') | |
| 16 | 18 | def test_call_process_calls_execute(self, git): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,20 +7,18 @@ | |||
| 7 | 7 | from test.testlib import * | |
| 8 | 8 | from git import * | |
| 9 | 9 | ||
| 10 | - class TestHead(object): | ||
| 11 | - def setup(self): | ||
| 12 | - self.repo = Repo(GIT_REPO) | ||
| 10 | + class TestHead(TestBase): | ||
| 13 | 11 | ||
| 14 | 12 | def test_base(self): | |
| 15 | - for head in self.repo.heads: | ||
| 13 | + for head in self.rorepo.heads: | ||
| 16 | 14 | assert head.name | |
| 17 | 15 | assert "refs/heads" in head.path | |
| 18 | 16 | # END for each head | |
| 19 | 17 | ||
| 20 | 18 | @patch_object(Git, '_call_process') | |
| 21 | 19 | def test_ref_with_path_component(self, git): | |
| 22 | 20 | git.return_value = fixture('for_each_ref_with_path_component') | |
| 23 | - head = self.repo.heads[0] | ||
| 21 | + head = self.rorepo.heads[0] | ||
| 24 | 22 | ||
| 25 | 23 | assert_equal('refactoring/feature1', head.name) | |
| 26 | 24 | assert_true(git.called) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,15 +10,11 @@ | |||
| 10 | 10 | import os | |
| 11 | 11 | import tempfile | |
| 12 | 12 | ||
| 13 | - class TestTree(TestCase): | ||
| 13 | + class TestTree(TestBase): | ||
| 14 | 14 | ||
| 15 | - @classmethod | ||
| 16 | - def setUpAll(cls): | ||
| 17 | - cls.repo = Repo(GIT_REPO) | ||
| 18 | - | ||
| 19 | 15 | def test_base(self): | |
| 20 | 16 | # read from file | |
| 21 | - index = Index.from_file(self.repo, fixture_path("index")) | ||
| 17 | + index = Index.from_file(self.rorepo, fixture_path("index")) | ||
| 22 | 18 | assert index.entries | |
| 23 | 19 | assert index.version > 0 | |
| 24 | 20 | ||
@@ -31,7 +27,7 @@ def test_base(self): | |||
| 31 | 27 | # END for each method | |
| 32 | 28 | ||
| 33 | 29 | # test stage | |
| 34 | - index_merge = Index.from_file(self.repo, fixture_path("index_merge")) | ||
| 30 | + index_merge = Index.from_file(self.rorepo, fixture_path("index_merge")) | ||
| 35 | 31 | assert len(index_merge.entries) == 106 | |
| 36 | 32 | assert len(list(e for e in index_merge.entries.itervalues() if e.stage != 0 )) | |
| 37 | 33 | ||
@@ -50,7 +46,7 @@ def test_base(self): | |||
| 50 | 46 | def _cmp_tree_index(self, tree, index): | |
| 51 | 47 | # fail unless both objects contain the same paths and blobs | |
| 52 | 48 | if isinstance(tree, str): | |
| 53 | - tree = self.repo.commit(tree).tree | ||
| 49 | + tree = self.rorepo.commit(tree).tree | ||
| 54 | 50 | ||
| 55 | 51 | num_blobs = 0 | |
| 56 | 52 | for blob in tree.traverse(predicate = lambda e: e.type == "blob"): | |
@@ -65,17 +61,17 @@ def test_from_tree(self): | |||
| 65 | 61 | other_sha = "39f85c4358b7346fee22169da9cad93901ea9eb9" | |
| 66 | 62 | ||
| 67 | 63 | # simple index from tree | |
| 68 | - base_index = Index.from_tree(self.repo, common_ancestor_sha) | ||
| 64 | + base_index = Index.from_tree(self.rorepo, common_ancestor_sha) | ||
| 69 | 65 | assert base_index.entries | |
| 70 | 66 | self._cmp_tree_index(common_ancestor_sha, base_index) | |
| 71 | 67 | ||
| 72 | 68 | # merge two trees - its like a fast-forward | |
| 73 | - two_way_index = Index.from_tree(self.repo, common_ancestor_sha, cur_sha) | ||
| 69 | + two_way_index = Index.from_tree(self.rorepo, common_ancestor_sha, cur_sha) | ||
| 74 | 70 | assert two_way_index.entries | |
| 75 | 71 | self._cmp_tree_index(cur_sha, two_way_index) | |
| 76 | 72 | ||
| 77 | 73 | # merge three trees - here we have a merge conflict | |
| 78 | - three_way_index = Index.from_tree(self.repo, common_ancestor_sha, cur_sha, other_sha) | ||
| 74 | + three_way_index = Index.from_tree(self.rorepo, common_ancestor_sha, cur_sha, other_sha) | ||
| 79 | 75 | assert len(list(e for e in three_way_index.entries.values() if e.stage != 0)) | |
| 80 | 76 | ||
| 81 | 77 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,9 +8,7 @@ | |||
| 8 | 8 | from git import * | |
| 9 | 9 | from time import time | |
| 10 | 10 | ||
| 11 | - class TestPerformance(object): | ||
| 12 | - def setup(self): | ||
| 13 | - self.repo = Repo(GIT_REPO) | ||
| 11 | + class TestPerformance(TestBase): | ||
| 14 | 12 | ||
| 15 | 13 | def test_iteration(self): | |
| 16 | 14 | num_objs = 0 | |
@@ -21,7 +19,7 @@ def test_iteration(self): | |||
| 21 | 19 | # return quite a lot of commits, we just take one and hence abort the operation | |
| 22 | 20 | ||
| 23 | 21 | st = time() | |
| 24 | - for c in self.repo.iter_commits('0.1.6'): | ||
| 22 | + for c in self.rorepo.iter_commits('0.1.6'): | ||
| 25 | 23 | num_commits += 1 | |
| 26 | 24 | c.author | |
| 27 | 25 | c.authored_date | |
| Back | FazBrowse Home | New Git URL |
0 commit comments