from datetime import datetime, timezone, timedelta import rtoml obj = { 'title': 'TOML Example', 'owner': { 'dob': datetime(1979, 5, 27, 7, 32, tzinfo=timezone(timedelta(hours=-8))), 'name': 'Tom Preston-Werner', }, 'database': { 'connection_max': 5000, 'enabled': True, 'ports': [8001, 8001, 8002], 'server': '192.168.1.1', }, } loaded_obj = rtoml.load("""\ # This is a TOML document. title = "TOML Example" [owner] name = "Tom Preston-Werner" dob = 1979-05-27T07:32:00-08:00 # First class dates [database] server = "192.168.1.1" ports = [8001, 8001, 8002] connection_max = 5000 enabled = true """) assert loaded_obj == obj assert rtoml.dumps(obj) == """\ title = "TOML Example" [owner] dob = 1979-05-27T07:32:00-08:00 name = "Tom Preston-Werner" [database] connection_max = 5000 enabled = true server = "192.168.1.1" ports = [8001, 8001, 8002] """