class TestProjectData(PyironTestCase): @classmethod def setUpClass(cls): cls.file_location = dirname(abspath(__file__)).replace("\\", "/") cls.project_name = join(cls.file_location, "test_project") @classmethod def tearDownClass(cls): try: remove(join(cls.file_location, "pyiron.log")) except FileNotFoundError: pass def setUp(self): self.project = Project(self.project_name) def tearDown(self): self.project.remove(enable=True) def test_data(self): self.assertRaises(KeyError, self.project.data.read) self.project.data.foo = "foo" self.project.data.write() self.project.data.read() self.assertEqual(1, len(self.project.data)) project2 = Project(self.project_name) self.assertEqual(1, len(project2.data)) self.assertEqual(self.project.data.foo, project2.data.foo) def test_iterjobs(self): try: for j in self.project.iter_jobs(): pass except: self.fail( "Iterating over empty project should not raise exception.") try: for j in self.project.iter_jobs(status="finished"): pass except: self.fail( "Iterating over empty project with set status flag should not raise exception." ) def test_create_job_name(self): self.assertEqual(self.project.create.job_name(['job', 0.1]), 'job_0d1') self.assertEqual( self.project.create.job_name(['job', 0.1], special_symbols={'.': 'c'}), 'job_0c1') self.assertEqual( self.project.create.job_name(['job', 1.0000000000005]), 'job_1d0') self.assertEqual( self.project.create.job_name(['job', 1.0000000000005], ndigits=None), 'job_1d0000000000005')
class TestProjectData(unittest.TestCase): @classmethod def setUpClass(cls): cls.file_location = dirname(abspath(__file__)).replace("\\", "/") cls.project_name = join(cls.file_location, "test_project") @classmethod def tearDownClass(cls): try: remove(join(cls.file_location, "pyiron.log")) except FileNotFoundError: pass def setUp(self): self.project = Project(self.project_name) def tearDown(self): self.project.remove(enable=True) def test_data(self): self.assertRaises(KeyError, self.project.data.read) self.project.data.foo = "foo" self.project.data.write() self.project.data.read() self.assertEqual(1, len(self.project.data)) project2 = Project(self.project_name) self.assertEqual(1, len(project2.data)) self.assertEqual(self.project.data.foo, project2.data.foo) def test_iterjobs(self): try: for j in self.project.iter_jobs(): pass except: self.fail( "Iterating over empty project should not raise exception.") try: for j in self.project.iter_jobs(status="finished"): pass except: self.fail( "Iterating over empty project with set status flag should not raise exception." )