Mercurial > kallithea
changeset 7212:4077ea3ff4f2
tests: vcs: split off repo creation helpers
test_changesets.py needs to create a repository, and is currently
duplicating some of the base setup code.
Instead, split out the setup_class method to allow reuse.
Note that the repo_path variable previously registered to 'self' is not
actually used by anyone, and moreover is not actually necessary as the path
can be obtained via the repo object too. Therefore, just make it a local
variable.
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 16 Mar 2018 21:32:01 +0100 |
parents | d8f820acf417 |
children | 01b58775d719 |
files | kallithea/tests/vcs/base.py |
diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/tests/vcs/base.py Fri Mar 16 22:07:58 2018 +0100 +++ b/kallithea/tests/vcs/base.py Fri Mar 16 21:32:01 2018 +0100 @@ -20,8 +20,6 @@ It is required to set following attributes at subclass: - ``backend_alias``: alias of used backend (see ``vcs.BACKENDS``) - - ``repo_path``: path to the repository which would be created for set of - tests - ``recreate_repo_per_test``: If set to ``False``, repo would NOT be created before every single test. Defaults to ``True``. """ @@ -63,8 +61,17 @@ def setup_class(cls): Backend = cls.get_backend() cls.backend_class = Backend - cls.repo_path = get_new_dir(str(time.time())) - cls.repo = Backend(cls.repo_path, create=True) + cls.setup_repo(Backend) + + @classmethod + def setup_empty_repo(cls, backend): + repo_path = get_new_dir(str(time.time())) + repo = backend(repo_path, create=True) + return repo + + @classmethod + def setup_repo(cls, backend): + cls.repo = cls.setup_empty_repo(backend) cls.imc = cls.repo.in_memory_changeset cls.default_branch = cls.repo.DEFAULT_BRANCH_NAME @@ -82,4 +89,4 @@ def setup_method(self, method): if getattr(self, 'recreate_repo_per_test', False): - self.__class__.setup_class() + self.setup_repo(self.backend_class)