def test_ordered(): from toml import ordered as toml_ordered encoder = toml_ordered.TomlOrderedEncoder() decoder = toml_ordered.TomlOrderedDecoder() o = toml.loads(toml.dumps(TEST_DICT, encoder=encoder), decoder=decoder) assert o == toml.loads(toml.dumps(TEST_DICT, encoder=encoder), decoder=decoder)
def write_template(path, temp, header='field_name'): to_dump = {header: temp} # workaround for bug that should be fixed. see comments on https://github.com/uiri/toml/pull/248 fstring = toml.dumps(to_dump, encoder=toml_ordered.TomlOrderedEncoder()) with open(path, 'w') as f: f.write(fstring)
assert o == loads(dumps(o, encoder=encoder)) d = {'a': np.array([1, 3], dtype=np.int32)} o = loads(dumps(d, encoder=encoder)) assert o == loads(dumps(o, encoder=encoder)) d = {'a': np.array([1, 3], dtype=np.int16)} o = loads(dumps(d, encoder=encoder)) assert o == loads(dumps(o, encoder=encoder)) @pytest.mark.parametrize( "encoder_cls", [ pytest.param(toml_ordered.TomlOrderedEncoder, id="type"), pytest.param(toml_ordered.TomlOrderedEncoder(), id="instance"), ] ) @pytest.mark.parametrize( "decoder_cls", [ pytest.param(toml_ordered.TomlOrderedDecoder, id="type"), pytest.param(toml_ordered.TomlOrderedDecoder(), id="instance"), ] ) def test_ordered(encoder_cls, decoder_cls): o: Dict[str, Any] = loads(dumps(TEST_DICT, encoder=encoder_cls), decoder=decoder_cls) assert o == loads(dumps(TEST_DICT, encoder=encoder_cls), decoder=decoder_cls) def test_tuple():