コード例 #1
0
ファイル: test_config.py プロジェクト: PyUtilib/pyutilib
    def test_load5(self):
        """Test load method"""
        PluginGlobals.add_env("testing.config_loading")

        class TMP2(Plugin):

            def __init__(self):
                declare_option("a")
                declare_option("b", cls=FileOption)
                declare_option("c")
                declare_option("xx", section_re='globals.*')

        config = Configuration()
        tmp2 = TMP2()
        config.load(currdir + "config4.ini")
        #config.pprint()
        if False and sys.platform == "win32":
            #
            # A hack, to ensure cross-platform portability of this test
            #
            e = ExtensionPoint(IFileOption)
            for ep in e.extensions():
                ep.set_value("/dev/null", raw=True)
        #PluginGlobals.pprint()
        config.save(currdir + "config4.out")
        #print config
        self.assertFileEqualsBaseline(
            currdir + "config4.out", currdir + "config4.txt", filter=filter)
        pyutilib.misc.setup_redirect(currdir + "log2.out")
        config.pprint()
        pyutilib.misc.reset_redirect()
        self.assertFileEqualsBaseline(
            currdir + "log2.out", currdir + "log2.txt", filter=filter)
        PluginGlobals.remove_env(
            "testing.config_loading", cleanup=True, singleton=False)
コード例 #2
0
 def test_save2(self):
     """Test save method"""
     config = Configuration()
     try:
         config.save(None)
         self.fail("expected error")
     except ConfigurationError:
         pass
コード例 #3
0
ファイル: test_config.py プロジェクト: PyUtilib/pyutilib
 def test_save2(self):
     """Test save method"""
     config = Configuration()
     try:
         config.save(None)
         self.fail("expected error")
     except ConfigurationError:
         pass
コード例 #4
0
ファイル: test_config.py プロジェクト: PyUtilib/pyutilib
 def test_save1(self):
     """Test save method"""
     config = Configuration()
     config.load(currdir + "config1.ini")
     #
     # A hack, to ensure cross-platform portability of this test
     #
     if False and sys.platform == "win32":
         e = ExtensionPoint(IFileOption)
         for ep in e.extensions():
             if ep.enabled():
                 ep.set_value("/dev/null", raw=True)
     config.save(currdir + "config1.out")
     #PluginGlobals.pprint()
     self.assertFileEqualsBaseline(
         currdir + "config1.out", currdir + "config1.txt", filter=filter)
コード例 #5
0
 def test_save1(self):
     """Test save method"""
     config = Configuration()
     config.load(currdir + "config1.ini")
     #
     # A hack, to ensure cross-platform portability of this test
     #
     if False and sys.platform == "win32":
         e = ExtensionPoint(IFileOption)
         for ep in e.extensions():
             if ep.enabled():
                 ep.set_value("/dev/null", raw=True)
     config.save(currdir + "config1.out")
     #PluginGlobals.pprint()
     self.assertFileEqualsBaseline(currdir + "config1.out",
                                   currdir + "config1.txt",
                                   filter=filter)
コード例 #6
0
    def test_load5(self):
        """Test load method"""
        PluginGlobals.add_env("testing.config_loading")

        class TMP2(Plugin):
            def __init__(self):
                declare_option("a")
                declare_option("b", cls=FileOption)
                declare_option("c")
                declare_option("xx", section_re='globals.*')

        config = Configuration()
        tmp2 = TMP2()
        config.load(currdir + "config4.ini")
        #config.pprint()
        if False and sys.platform == "win32":
            #
            # A hack, to ensure cross-platform portability of this test
            #
            e = ExtensionPoint(IFileOption)
            for ep in e.extensions():
                ep.set_value("/dev/null", raw=True)
        #PluginGlobals.pprint()
        config.save(currdir + "config4.out")
        #print config
        self.assertFileEqualsBaseline(currdir + "config4.out",
                                      currdir + "config4.txt",
                                      filter=filter)
        pyutilib.misc.setup_redirect(currdir + "log2.out")
        config.pprint()
        pyutilib.misc.reset_redirect()
        self.assertFileEqualsBaseline(currdir + "log2.out",
                                      currdir + "log2.txt",
                                      filter=filter)
        PluginGlobals.remove_env("testing.config_loading",
                                 cleanup=True,
                                 singleton=False)