Commit 645bf229 authored by Jason Swails's avatar Jason Swails
Browse files

Use tempfile to make a file.

parent efce20c2
import unittest
import tempfile
import numpy as np
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
......@@ -10,13 +9,14 @@ import os
class TestDCDFile(unittest.TestCase):
def test_dcd(self):
""" Test the DCD file """
fname = tempfile.mktemp(suffix='.dcd')
pdbfile = app.PDBFile('systems/alanine-dipeptide-implicit.pdb')
natom = len(list(pdbfile.topology.atoms()))
dcd = app.DCDFile(open('test.dcd', 'w'), pdbfile.topology, 0.001)
dcd = app.DCDFile(open(fname, 'w'), pdbfile.topology, 0.001)
for i in range(5):
dcd.writeModel([mm.Vec3(random(), random(), random()) for j in range(natom)]*unit.angstroms)
dcd._file.close()
os.remove('test.dcd')
os.remove(fname)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment