コード例 #1
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
 def test_save_no_config(self):
     """Test saving uninitialized config
     """
     conf["a"] = 12
     with tempfile.NamedTemporaryFile() as temp:
         conf.save(temp.name)
         conf.reset_instance()
         self.assertNotIn("a", conf)
         conf.load(temp.name)
         self.assertIn("a", conf)
         self.assertEqual(int(conf["a"]), 12)
コード例 #2
0
 def test_save_no_config(self):
     """Test saving uninitialized config
     """
     conf['a'] = 12
     with tempfile.NamedTemporaryFile() as temp:
         conf.save(temp.name)
         conf.reset_instance()
         self.assertNotIn('a', conf)
         conf.load(temp.name)
         self.assertIn('a', conf)
         self.assertEqual(int(conf['a']), 12)
コード例 #3
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
    def test_save_load_config(self):
        """Test saving and reloading conf
        """
        conf.load(self.filename)

        filename = tempfile.mkstemp()[1]
        conf.save(filename)

        # Destroy configuration
        conf.reset_instance()
        self.assertRaises(KeyError, lambda: conf["section_1.a"])

        conf.load(filename)
        a_conf = conf["section_1.a"]
        self.assertEqual(a_conf, "12")
        b_conf = conf["section_1.b"]
        self.assertEqual(b_conf, "13")
        c_conf = conf["section_2.c"]
        self.assertEqual(c_conf, "True")

        self.assertTrue(os.path.isfile(filename))
        # Clean up
        os.remove(filename)
コード例 #4
0
    def test_save_load_config(self):
        """Test saving and reloading conf
        """
        conf.load(self.filename)

        filename = tempfile.mkstemp()[1]
        conf.save(filename)

        # Destroy configuration
        conf.reset_instance()
        self.assertRaises(KeyError, lambda: conf['section_1.a'])

        conf.load(filename)
        a_conf = conf['section_1.a']
        self.assertEqual(a_conf, '12')
        b_conf = conf['section_1.b']
        self.assertEqual(b_conf, '13')
        c_conf = conf['section_2.c']
        self.assertEqual(c_conf, 'True')

        self.assertTrue(os.path.isfile(filename))
        # Clean up
        os.remove(filename)
コード例 #5
0
ファイル: experiment.py プロジェクト: danorama/pyexperiment
def save_config(filename):
    """Save a configuration file to a filename
    """
    conf.save(filename)
    print("Wrote configuration to '%s'" % filename)
コード例 #6
0
def save_config(filename):
    """Save a configuration file to a filename
    """
    conf.save(filename)
    print("Wrote configuration to '%s'" % filename)