From 5e692032fee5c2f0303557c5e9f9ff2d7aeea2d0 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 26 Jan 2019 11:44:51 +0100 Subject: [PATCH] move the BorgQtTestCase into its own file --- tests/test_config.py | 23 ++++------------------- tests/testcase.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 tests/testcase.py diff --git a/tests/test_config.py b/tests/test_config.py index c44603a..df09b95 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -13,28 +13,13 @@ import context from main_window import MainWindow from config import Config from helper import BorgException +from testcase import BorgQtTestCase app = QApplication(sys.argv) -def fxn(): - warnings.warn("deprecated", DeprecationWarning) - - -class BorgQtConfigTestCase(unittest.TestCase): - def setUp(self): - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - fxn() - self.form = MainWindow() - - self.dir_path = os.path.dirname(os.path.realpath(__file__)) - self.config_path = os.path.join(self.dir_path, - '../docs/borg_qt.conf.example') - - -class TestConfiguration(BorgQtConfigTestCase): +class TestConfiguration(BorgQtTestCase): def test_read_configuration(self): self.form.config._get_path = MagicMock(return_value=self.config_path) self.form.config.read() @@ -73,7 +58,7 @@ class TestConfiguration(BorgQtConfigTestCase): os.environ['BORG_PASSPHRASE']) -class TestWriteConfiguration(BorgQtConfigTestCase): +class TestWriteConfiguration(BorgQtTestCase): def tearDown(self): if os.path.exists(self.form.config.path): os.remove(self.form.config.path) @@ -89,7 +74,7 @@ class TestWriteConfiguration(BorgQtConfigTestCase): config['borgqt']['password']) -class TestGuiConfiguration(BorgQtConfigTestCase): +class TestGuiConfiguration(BorgQtTestCase): def setUp(self): super().setUp() self.form.config.read() diff --git a/tests/testcase.py b/tests/testcase.py new file mode 100644 index 0000000..0294cd1 --- /dev/null +++ b/tests/testcase.py @@ -0,0 +1,22 @@ +import os + +import unittest +import warnings + +from main_window import MainWindow + + +def fxn(): + warnings.warn("deprecated", DeprecationWarning) + + +class BorgQtTestCase(unittest.TestCase): + def setUp(self): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + fxn() + self.form = MainWindow() + + self.dir_path = os.path.dirname(os.path.realpath(__file__)) + self.config_path = os.path.join(self.dir_path, + '../docs/borg_qt.conf.example')