
import unittest
from pathlib import Path

from pymatgen.util.testing import PymatgenTest
from pymatgen.io.cp2k.outputs import Cp2kOutput

MODULE_DIR = Path(__file__).resolve().parent


class SetTest(PymatgenTest):

    def setUp(self):
        self.out = Cp2kOutput(filename='../test_files/cp2k.out', auto_load=True)

    def test_files(self):
        self.out.parse_files()
        self.assertEqual(len(self.out.filenames['PDOS']), 2)

    def test(self):
        self.assertEqual(self.out.spin_polarized, False)
        self.assertEqual(self.out.completed, True)
        self.assertEqual(self.out.num_warnings, [[1]])
        self.assertEqual(self.out.run_type.upper(), 'GEO_OPT')


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


import unittest
from pathlib import Path

from pymatgen.util.testing import PymatgenTest
from pymatgen.io.cp2k.outputs import Cp2kOutput

TEST_FILES = Path(__file__).parent.parent.joinpath("test_files").resolve()


class SetTest(PymatgenTest):

    def setUp(self):
        self.out = Cp2kOutput(filename=TEST_FILES / "cp2k.out", auto_load=True)

    def test_files(self):
        self.out.parse_files()
        self.assertEqual(len(self.out.filenames['PDOS']), 2)

    def test(self):
        self.assertEqual(self.out.spin_polarized, False)
        self.assertEqual(self.out.completed, True)
        self.assertEqual(self.out.num_warnings, [[1]])
        self.assertEqual(self.out.run_type.upper(), 'GEO_OPT')


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

Switch output to to use TEST_FILES path
Switch output to to use TEST_FILES path
  
  import unittest
  from pathlib import Path
  
  from pymatgen.util.testing import PymatgenTest
  from pymatgen.io.cp2k.outputs import Cp2kOutput
  
- MODULE_DIR = Path(__file__).resolve().parent
+ TEST_FILES = Path(__file__).parent.parent.joinpath("test_files").resolve()
  
  
  class SetTest(PymatgenTest):
  
      def setUp(self):
-         self.out = Cp2kOutput(filename='../test_files/cp2k.out', auto_load=True)
+         self.out = Cp2kOutput(filename=TEST_FILES / "cp2k.out", auto_load=True)
  
      def test_files(self):
          self.out.parse_files()
          self.assertEqual(len(self.out.filenames['PDOS']), 2)
  
      def test(self):
          self.assertEqual(self.out.spin_polarized, False)
          self.assertEqual(self.out.completed, True)
          self.assertEqual(self.out.num_warnings, [[1]])
          self.assertEqual(self.out.run_type.upper(), 'GEO_OPT')
  
  
  if __name__ == "__main__":
      unittest.main()
  
Switch output to to use TEST_FILES path
## Code Before:

import unittest
from pathlib import Path

from pymatgen.util.testing import PymatgenTest
from pymatgen.io.cp2k.outputs import Cp2kOutput

MODULE_DIR = Path(__file__).resolve().parent


class SetTest(PymatgenTest):

    def setUp(self):
        self.out = Cp2kOutput(filename='../test_files/cp2k.out', auto_load=True)

    def test_files(self):
        self.out.parse_files()
        self.assertEqual(len(self.out.filenames['PDOS']), 2)

    def test(self):
        self.assertEqual(self.out.spin_polarized, False)
        self.assertEqual(self.out.completed, True)
        self.assertEqual(self.out.num_warnings, [[1]])
        self.assertEqual(self.out.run_type.upper(), 'GEO_OPT')


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

## Instruction:
Switch output to to use TEST_FILES path
## Code After:

import unittest
from pathlib import Path

from pymatgen.util.testing import PymatgenTest
from pymatgen.io.cp2k.outputs import Cp2kOutput

TEST_FILES = Path(__file__).parent.parent.joinpath("test_files").resolve()


class SetTest(PymatgenTest):

    def setUp(self):
        self.out = Cp2kOutput(filename=TEST_FILES / "cp2k.out", auto_load=True)

    def test_files(self):
        self.out.parse_files()
        self.assertEqual(len(self.out.filenames['PDOS']), 2)

    def test(self):
        self.assertEqual(self.out.spin_polarized, False)
        self.assertEqual(self.out.completed, True)
        self.assertEqual(self.out.num_warnings, [[1]])
        self.assertEqual(self.out.run_type.upper(), 'GEO_OPT')


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