Example #1
0
    def test_lock(self):
        rc = RunControl()
        rc_saved = dict(rc)
        rc.unlock()
        rc.clear()

        rc.lock()

        with self.assertRaises(KeyError):
            rc.a.b = 1

        rc.unlock()
        rc.a.b = 1
        self.assertEqual(rc.a.b, 1)
        rc.lock()
        self.assertEqual(rc.a.b, 1)

        rc.a.b = 2
        self.assertEqual(rc.a.b, 2)

        rc.clear()
        rc.update(**rc_saved)
Example #2
0
    def test_str(self):
        rc = RunControl()
        rc_saved = dict(rc)
        rc.unlock()
        rc.clear()

        rc.fill_type = 'int'
        rc.plot.baseline = 'bottom'
        rc.plot.patch.alpha = 0.6

        rc.lock()

        rc_str = '''\
fill_type = 'int'
plot.baseline = 'bottom'
plot.patch.alpha = 0.6'''

        self.assertEqual(rc_str, str(rc))
        rc.clear()
        rc.update(**rc_saved)