Esempio n. 1
0
    def test_read_comment(self):
        comment = random_comment()
        num_atoms = random.randint(1,100)
        crds = random_crds(num_atoms)

        with tfu.TempfileSession() as tfs:
            file_name = tfs.temp_file_name('.rst')

            with rst.open(file_name, 'w', comment=comment) as f:
                f.write(crds)

            with rst.open(file_name, 'r') as f:
                self.assertEqual(f.comment, comment)
Esempio n. 2
0
    def test_read_comment(self):

        with open(test_file('expected_cpr_comment')) as f:
            expected_comment = f.next()[:-1]

        with rst.open(test_file('cpr')) as f:
            self.assertEqual(f.comment, expected_comment)
Esempio n. 3
0
    def test_read_crd(self):
        with open(test_file('expected_cpr_crds')) as f:
            expected_crds = [float(x) for x in f.read().split()]

        with rst.open(test_file('cpr')) as f:
            crds = f.next()

        for (expected, crd) in it.izip_longest(expected_crds, crds):
            self.assertAlmostEqual(expected, crd, 3)
Esempio n. 4
0
    def test_read_crds(self):
        comment = random_comment()
        num_atoms = random.randint(1,100)

        num_crds = 1 # random.randint(1, 10)
        crdss = [random_crds(num_atoms) for count in xrange(num_crds)]

        with tfu.TempfileSession() as tfs:
            file_name = tfs.temp_file_name('.rst')

            with rst.open(file_name, 'w', comment=comment) as f:

                for crds in crdss:
                    f.write(crds)

            with rst.open(file_name, 'r') as f:
                for expected_crds, read_crds in it.izip_longest(crdss, f):
                    self.assertNotEqual(expected_crds, None)
                    self.assertNotEqual(read_crds, None)
                    for (expected, crd) in it.izip_longest(expected_crds, read_crds):
                        self.assertAlmostEqual(expected, crd, 3)