dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00179
[PATCH 05/10] tests/compat/server_utils: Factor out several methods.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I6ef1e4b2cca82042aa964a7355558300bfa25f6a
---
NEWS | 2 ++
dulwich/tests/compat/server_utils.py | 34 ++++++++++++++++++++++------------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/NEWS b/NEWS
index 7f86a42..88efb2c 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,8 @@
* Use real in-memory objects rather than stubs for server tests.
(Dave Borowitz)
+ * Refactor some of dulwich.tests.compat.server_utils. (Dave Borowitz)
+
API CHANGES
* ObjectStore.iter_tree_contents now walks contents in depth-first, sorted
diff --git a/dulwich/tests/compat/server_utils.py b/dulwich/tests/compat/server_utils.py
index 2230d2c..0c5dce3 100644
--- a/dulwich/tests/compat/server_utils.py
+++ b/dulwich/tests/compat/server_utils.py
@@ -43,36 +43,46 @@ class ServerTests(object):
"""
def setUp(self):
- self._old_repo = import_repo('server_old.export')
- self._new_repo = import_repo('server_new.export')
+ self._old_repo = None
+ self._new_repo = None
self._server = None
def tearDown(self):
if self._server is not None:
self._server.shutdown()
self._server = None
- tear_down_repo(self._old_repo)
- tear_down_repo(self._new_repo)
+ if self._old_repo is not None:
+ tear_down_repo(self._old_repo)
+ if self._new_repo is not None:
+ tear_down_repo(self._new_repo)
+
+ def import_repos(self):
+ self._old_repo = import_repo('server_old.export')
+ self._new_repo = import_repo('server_new.export')
+
+ def url(self, port):
+ return '%s://localhost:%s/' % (self.protocol, port)
+
+ def branch_args(self, branches=None):
+ if branches is None:
+ branches = ['master', 'branch']
+ return ['%s:%s' % (b, b) for b in branches]
def test_push_to_dulwich(self):
+ self.import_repos()
self.assertReposNotEqual(self._old_repo, self._new_repo)
port = self._start_server(self._old_repo)
- all_branches = ['master', 'branch']
- branch_args = ['%s:%s' % (b, b) for b in all_branches]
- url = '%s://localhost:%s/' % (self.protocol, port)
- run_git_or_fail(['push', url] + branch_args,
+ run_git_or_fail(['push', self.url(port)] + self.branch_args(),
cwd=self._new_repo.path)
self.assertReposEqual(self._old_repo, self._new_repo)
def test_fetch_from_dulwich(self):
+ self.import_repos()
self.assertReposNotEqual(self._old_repo, self._new_repo)
port = self._start_server(self._new_repo)
- all_branches = ['master', 'branch']
- branch_args = ['%s:%s' % (b, b) for b in all_branches]
- url = '%s://localhost:%s/' % (self.protocol, port)
- run_git_or_fail(['fetch', url] + branch_args,
+ run_git_or_fail(['fetch', self.url(port)] + self.branch_args(),
cwd=self._old_repo.path)
# flush the pack cache so any new packs are picked up
self._old_repo.object_store._pack_cache = None
--
1.7.1
References