1import sys 2import yaml 3 4 5def main(): 6 # various smoke tests on an installed PyYAML with extension 7 if not getattr(yaml, '_yaml', None): 8 raise Exception('C extension is not available at `yaml._yaml`') 9 10 print('embedded libyaml version is {0}'.format(yaml._yaml.get_version_string())) 11 12 for loader, dumper in [(yaml.CLoader, yaml.CDumper), (yaml.Loader, yaml.Dumper)]: 13 testyaml = 'dude: mar' 14 loaded = yaml.load(testyaml, Loader=loader) 15 dumped = yaml.dump(loaded, Dumper=dumper) 16 if testyaml != dumped.strip(): 17 raise Exception('roundtrip failed with {0}/{1}'.format(loader, dumper)) 18 print('smoke test passed for {0}'.format(sys.executable)) 19 20 21if __name__ == '__main__': 22 main()