def tearDownClass(cls): project = Project( os.path.join(os.path.dirname(os.path.abspath(__file__)), "hdf5_content") ) ham = project.load(project.get_job_ids()[0]) ham.remove() project.remove(enable=True)
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." )
def tearDownClass(cls): file_location = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(file_location, "master_copy")) project.remove(enforce=True, enable=True)
def test_load_file_ProjectHDF(self): pr = Project(self.current_dir + '/test_pr') pr_hdf = load_file(self.current_dir + '/test_data.h5', project=pr) self.assertIsInstance(pr_hdf, ProjectHDFio) self.assertEqual(pr_hdf['content/key'], 'value') pr.remove(enable=True)
def tearDownClass(cls): file_location = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(file_location, "testing_childids")) project.remove_jobs(recursive=True, silently=True) project.remove(enable=True)
def tearDownClass(cls): file_location = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(file_location, "test_genericjob")) project.remove(enable=True)
def tearDownClass(cls): file_location = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(file_location, "jobs_testing")) project.remove(enforce=True)