Example #1
0
 def test_42_dump_w_special_option(self):
     TT.Parser().dump(self.cnf, self.cpath, use_single_float=True)
     cnf = TT.Parser().load(self.cpath)
     ref = copy.deepcopy(self.cnf)
     ref[_bytes("a")] = cnf[_bytes("a")]  # single float value.
     self.assertFalse(dicts_equal(cnf, self.cnf), str(cnf))
     self.assertTrue(dicts_equal(cnf, ref), str(cnf))
Example #2
0
#
# Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com>
# License: MIT
#
# pylint: disable=missing-docstring
import anyconfig.backend.bson as TT
import anyconfig.backend.tests.ini

from anyconfig.compat import OrderedDict as ODict, IS_PYTHON_3
from anyconfig.tests.common import to_bytes as _bytes


CNF_0 = ODict((("a", 0.1), ("b", _bytes("bbb")), ("sect0", ODict((("c", [_bytes("x"), _bytes("y"), _bytes("z")]),)))))


class Test10(anyconfig.backend.tests.ini.Test10):

    cnf = CNF_0
    cnf_s = TT.bson.BSON.encode(CNF_0)
    load_options = dict(as_class=dict)
    dump_options = dict(check_keys=True)

    if IS_PYTHON_3:
        is_order_kept = False  # FIXME: Make it work w/ python 3.

    def setUp(self):
        self.psr = TT.Parser()


class Test20(anyconfig.backend.tests.ini.Test20):
Example #3
0
# Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com>
# License: MIT
#
# pylint: disable=missing-docstring
import copy
import os.path
import unittest

import anyconfig.backend.msgpack as TT
import anyconfig.tests.common
import anyconfig.compat

from anyconfig.tests.common import dicts_equal, to_bytes as _bytes


CNF_0 = {_bytes("a"): 0.1,
         _bytes("b"): _bytes("bbb"),
         _bytes("sect0"): {_bytes("c"): [_bytes("x"), _bytes("y"),
                                         _bytes("z")]}}


class Test(unittest.TestCase):

    def setUp(self):
        self.cnf = CNF_0
        self.workdir = anyconfig.tests.common.setup_workdir()
        self.cpath = os.path.join(self.workdir, "test0.msgpack")
        self.packed = TT.msgpack.packb(self.cnf)
        open(self.cpath, 'wb').write(self.packed)

    def tearDown(self):
Example #4
0
 def test_22_load__optional_kwargs(self):
     cnf = TT.Parser().load(self.cpath, use_list=False)
     ref = copy.deepcopy(self.cnf)
     ref[_bytes("sect0")][_bytes("c")] = (_bytes("x"), _bytes("y"),
                                          _bytes("z"))
     self.assertTrue(dicts_equal(cnf, ref), str(cnf))
Example #5
0
#
# Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com>
# License: MIT
#
# pylint: disable=missing-docstring
from __future__ import absolute_import

import copy

import anyconfig.backend.msgpack as TT
import anyconfig.backend.tests.ini

from anyconfig.compat import OrderedDict as ODict, IS_PYTHON_3
from anyconfig.tests.common import dicts_equal, to_bytes as _bytes

CNF_0 = ODict(((_bytes("a"), 0.1), (_bytes("b"), _bytes("bbb")),
               (_bytes("sect0"),
                ODict(((_bytes("c"), [_bytes("x"),
                                      _bytes("y"),
                                      _bytes("z")]), )))))


class Test10(anyconfig.backend.tests.ini.Test10):

    cnf = CNF_0
    cnf_s = TT.msgpack.packb(CNF_0)

    if IS_PYTHON_3:
        is_order_kept = False  # FIXME: Make it work w/ python 3.

    def setUp(self):
Example #6
0
 def test_12_load__w_options(self):
     cnf = self.psr.load(self.cpath, use_list=False)
     ref = copy.deepcopy(self.cnf)
     ref[_bytes("sect0")][_bytes("c")] = (_bytes("x"), _bytes("y"),
                                          _bytes("z"))
     self.assertTrue(dicts_equal(cnf, ref), str(cnf))
Example #7
0
 def test_22_dumps__w_options(self):
     cnf = self.psr.loads(self.psr.dumps(self.cnf, use_single_float=True))
     ref = copy.deepcopy(self.cnf)
     ref[_bytes("a")] = cnf[_bytes("a")]  # single float value.
     self.assertFalse(dicts_equal(cnf, self.cnf), str(cnf))
     self.assertTrue(dicts_equal(cnf, ref), str(cnf))
Example #8
0
# Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com>
# License: MIT
#
# pylint: disable=missing-docstring
from __future__ import absolute_import

import copy

import anyconfig.backend.msgpack as TT
import anyconfig.backend.tests.ini

from anyconfig.compat import OrderedDict as ODict, IS_PYTHON_3
from anyconfig.tests.common import dicts_equal, to_bytes as _bytes


CNF_0 = ODict(((_bytes("a"), 0.1),
               (_bytes("b"), _bytes("bbb")),
               (_bytes("sect0"),
                ODict(((_bytes("c"),
                        [_bytes("x"), _bytes("y"), _bytes("z")]), )))))


class Test10(anyconfig.backend.tests.ini.Test10):

    cnf = CNF_0
    cnf_s = TT.msgpack.packb(CNF_0)

    if IS_PYTHON_3:
        is_order_kept = False  # FIXME: Make it work w/ python 3.

    def setUp(self):
Example #9
0
# Copyright (C) 2015 Satoru SATOH <ssato @ redhat.com>
# License: MIT
#
# pylint: disable=missing-docstring
import os.path
import unittest

import anyconfig.backend.bson as TT
import anyconfig.tests.common
import anyconfig.compat

from anyconfig.tests.common import dicts_equal, to_bytes as _bytes


CNF_0 = {"a": 0.1,
         "b": _bytes("bbb"),
         "sect0": {"c": [_bytes("x"), _bytes("y"), _bytes("z")]}}


class Test10(unittest.TestCase):

    def setUp(self):
        self.psr = TT.Parser()
        self.cnf = CNF_0
        self.cnf_s = TT.bson.BSON.encode(self.cnf)

    def test_10_loads(self):
        cnf = self.psr.loads(self.cnf_s)
        self.assertTrue(dicts_equal(cnf, self.cnf), str(cnf))

    def test_12_loads__optional_kwargs(self):