File: regression_io.py

package info (click to toggle)
cclib 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 55,300 kB
  • sloc: python: 23,276; makefile: 84; sh: 26
file content (40 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

from pathlib import Path

import unittest

import cclib


__filedir__ = Path(__file__).parent
__filepath__ = Path(__filedir__).resolve()
__regdir__ = (__filepath__ / ".." / "data" / "regression").resolve()


class XYZRegressionTests(unittest.TestCase):

    def test_xyz_not_turbomole(self):
        """Ensure XYZ file isn't misrecognized as a Turbomole file.

        From https://github.com/cclib/cclib/issues/1207.
        """
        fpath = __regdir__ / "io" / "xyz" / "1207.xyz"
        # ccopen assumes something is a parsable logfile and doesn't try any
        # fallback mechanisms.
        logfile = cclib.io.ccopen(str(fpath))
        assert logfile is None
        # ccread tries alternative file reading mechanisms.
        data = cclib.io.ccread(str(fpath))
        assert set(data.getattributes().keys()) == {
            "atomcoords", "atommasses", "atomnos", "natom"
        }


if __name__ == "__main__":
    unittest.main()