def test_duplicate_keywords():
 initialize()
 yamlfile = '{\n            "model": !obj:pylearn2.models.mlp.MLP {\n            "layers": [\n                     !obj:pylearn2.models.mlp.Sigmoid {\n                         "layer_name": \'h0\',\n                         "dim": 20,\n                         "sparse_init": 15,\n                     }],\n            "nvis": 784,\n            "nvis": 384,\n        }\n    }'
 try:
  load(yamlfile)
 except yaml.constructor.ConstructorError as e:
  message = str(e)
  assert message.endswith('found duplicate key (nvis)')
  pass
 except Exception as e:
  error_msg = ('Got the unexpected error: %s' % e)
  raise TypeError(error_msg)

def test_duplicate_keywords ( ) : initialize ( ) yamlfile = '{\n            "model": !obj:pylearn2.models.mlp.MLP {\n            "layers": [\n                     !obj:pylearn2.models.mlp.Sigmoid {\n                         "layer_name": \'h0\',\n                         "dim": 20,\n                         "sparse_init": 15,\n                     }],\n            "nvis": 784,\n            "nvis": 384,\n        }\n    }' try : load ( yamlfile ) except yaml . constructor . ConstructorError as e : message = str ( e ) assert message . endswith ( 'found duplicate key (nvis)' ) pass except Exception as e : error_msg = ( 'Got the unexpected error: %s' % e ) raise TypeError ( error_msg )
tests whether there are doublicate keywords in the yaml .