From 1ba856d2b3ff3fdbbd6bc3afb25701a7bcb57c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 1 Oct 2015 00:15:25 -0400 Subject: [PATCH] refactor: group test repo subroutine --- borg/testsuite/convert.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/borg/testsuite/convert.py b/borg/testsuite/convert.py index d48a0e05b..cb9f5ec4c 100644 --- a/borg/testsuite/convert.py +++ b/borg/testsuite/convert.py @@ -51,12 +51,16 @@ class ConversionTestCase(BaseTestCase): def tearDown(self): shutil.rmtree(self.tmppath) - def test_convert(self): + def check_repo(self, state = True): + if not state: + print("this will show an error, this is expected") self.repository = self.open(self.tmppath) - # check should fail because of magic number - print("this will show an error, it is expected") - assert not self.repository.check() # can't check raises() because check() handles the error + assert self.repository.check() is state # can't check raises() because check() handles the error self.repository.close() + + def test_convert(self): + # check should fail because of magic number + self.check_repo(False) print("opening attic repository with borg and converting") with pytest.raises(NotImplementedException): self.open(self.tmppath, repo_type = AtticRepositoryConverter).convert(dryrun=False) @@ -65,6 +69,4 @@ class ConversionTestCase(BaseTestCase): os.path.basename(self.key.path)) with open(keyfile, 'r') as f: assert f.read().startswith(KeyfileKey.FILE_ID) - self.repository = self.open(self.tmppath) - assert self.repository.check() - self.repository.close() + self.check_repo()