def test_namespace_to_dict(self):
     ns = Namespace()
     ns['w'] = 1
     ns['x.y'] = 2
     ns['x.z'] = 3
     dic1 = namespace_to_dict(ns)
     dic2 = ns.as_dict()
     self.assertEqual(dic1, dic2)
     self.assertIsNot(dic1, dic2)
 def test_as_dict(self):
     ns = Namespace()
     ns['w'] = 1
     ns['x.y'] = 2
     ns['x.z'] = 3
     ns['p'] = {'q': Namespace(r=4)}
     self.assertEqual(ns.as_dict(), {
         'w': 1,
         'x': {
             'y': 2,
             'z': 3
         },
         'p': {
             'q': {
                 'r': 4
             }
         }
     })
     self.assertEqual(Namespace().as_dict(), {})