Beispiel #1
0
class BackupTest(TestCase):

    def setUp(self):
        super(BackupTest, self).setUp()
        self.conf = Config(dict(a=1, b=2, c=[]))
        self.conf.extend(Config({'d': []}))

    def test_backup_context(self):
        with self.conf.backup_context():
            self.conf.root.a = 10
            assert self.conf.root.a == 10

        assert self.conf.root.a == 1

    def test_restore_no_backup(self):
        with self.assertRaises(exceptions.NoBackup):
            self.conf.restore()

    def test_discard(self):
        self.conf.backup()
        self.conf.discard_backup()
        with self.assertRaises(exceptions.NoBackup):
            self.conf.restore()

    def test_backup_copy(self):
        self.conf.backup()
        self.conf.root.c.append(0)
        self.conf.root.d.extend([2, 3])
        self.conf.restore()
        self.assertEqual(self.conf.root.c, [])
        self.assertEqual(self.conf.root.d, [])
Beispiel #2
0
class BackupTest(TestCase):

    def setUp(self):
        super(BackupTest, self).setUp()
        self.conf = Config(dict(a=1, b=2))

    def test__restore_no_backup(self):
        with self.assertRaises(exceptions.NoBackup):
            self.conf.restore()

    def test__discard(self):
        self.conf.backup()
        self.conf.discard_backup()
        with self.assertRaises(exceptions.NoBackup):
            self.conf.restore()