コード例 #1
0
    def test_load_unusual(self, text, data, tmpdir):
        tmp = tmpdir / "test.conf"
        tmp.write("# univention_ base.conf\n" + text)

        ucr = backend._ConfigRegistry(str(tmp))
        ucr.load()
        assert ucr.items() == data.items()
コード例 #2
0
    def test_busy(self, tmpdir):
        tmp = tmpdir / "test.conf"
        tmpdir.mkdir("test.conf.temp")

        ucr = backend._ConfigRegistry(str(tmp))
        with pytest.raises(EnvironmentError):
            ucr._save_file(str(tmp))
コード例 #3
0
 def _locked_app_ucr(cls, app):
     ucr_file = cls._get_app_ucr_filename(app)
     ucr = _ConfigRegistry(ucr_file)
     ucr.lock()
     try:
         ucr.load()
         yield ucr
     finally:
         ucr.unlock()
コード例 #4
0
    def test_load_backup(self, tmpdir):
        tmp = tmpdir / "test.conf"
        tmp.write("")
        bak = tmpdir / "test.conf.bak"
        bak.write("#\nfoo: bar")

        ucr = backend._ConfigRegistry(str(tmp))
        ucr.load()
        assert ucr["foo"] == "bar"
        assert tmp.size() > 0
コード例 #5
0
 def _get_app_ucr(cls, app):
     ucr_file = cls._get_app_ucr_filename(app)
     ucr = _ConfigRegistry(ucr_file)
     ucr.load()
     return ucr
コード例 #6
0
 def test_devnull(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.save()
     assert os.path.exists(os.path.devnull)
     assert not os.path.isfile(os.path.devnull)
コード例 #7
0
 def test_strict_value(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.strict_encoding = True
     with pytest.raises(backend.StrictModeException):
         ucr["key"] = b"\xff"
コード例 #8
0
 def test_strict_key(self):
     ucr = backend._ConfigRegistry(os.path.devnull)
     ucr.strict_encoding = True
     with pytest.raises(backend.StrictModeException):
         ucr[b'\xff'] = "val"