mirror of
https://github.com/schrodinger/pymol-open-source.git
synced 2026-06-04 20:04:21 +08:00
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
'''
|
|
unit tests for pymol.exporting geometry formats
|
|
'''
|
|
|
|
from pymol import cmd, testing
|
|
|
|
def file_get_contents(filename, mode='r'):
|
|
with open(filename, mode) as handle:
|
|
return handle.read()
|
|
|
|
class TestExportingGeom(testing.PyMOLTestCase):
|
|
|
|
def testVRML(self):
|
|
cmd.fragment('gly')
|
|
for rep in ['spheres', 'sticks', 'surface']:
|
|
cmd.show_as(rep)
|
|
with testing.mktemp('.wrl') as filename:
|
|
cmd.save(filename)
|
|
contents = file_get_contents(filename)
|
|
self.assertTrue(contents.startswith('#VRML V2'))
|
|
|
|
@testing.requires_version('1.8')
|
|
def testCOLLADA(self):
|
|
cmd.fragment('gly')
|
|
for rep in ['spheres', 'sticks', 'surface']:
|
|
cmd.show_as(rep)
|
|
with testing.mktemp('.dae') as filename:
|
|
cmd.save(filename)
|
|
contents = file_get_contents(filename)
|
|
self.assertTrue('<COLLADA' in contents)
|
|
|
|
@testing.requires('incentive')
|
|
@testing.requires_version('2.1')
|
|
def testSTL(self):
|
|
cmd.fragment('gly')
|
|
for rep in ['spheres', 'sticks', 'surface']:
|
|
cmd.show_as(rep)
|
|
with testing.mktemp('.stl') as filename:
|
|
cmd.save(filename)
|
|
contents = file_get_contents(filename, 'rb')
|
|
# 80 bytes header
|
|
# 4 bytes (uint32) number of triangles
|
|
self.assertTrue(len(contents) > 84)
|