88import math
99import os
1010import shutil
11+ import tempfile
1112import unittest
1213
13- from arc .common import ARC_TESTING_PATH
1414from arc .job .adapters .gaussian import GaussianAdapter , get_memory_headroom_fraction
1515from arc .level import Level
1616from arc .settings .settings import input_filenames , output_filenames , servers , submit_filenames
@@ -28,11 +28,13 @@ def setUpClass(cls):
2828 A method that is run before all unit tests in this class.
2929 """
3030 cls .maxDiff = None
31+ cls .project_directory = tempfile .mkdtemp (prefix = 'test_GaussianAdapter_' )
32+ cls .addClassCleanup (shutil .rmtree , cls .project_directory , ignore_errors = True )
3133 cls .job_1 = GaussianAdapter (execution_type = 'incore' ,
3234 job_type = 'composite' ,
3335 level = Level (method = 'cbs-qb3-paraskevas' ),
3436 project = 'test' ,
35- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
37+ project_directory = cls . project_directory ,
3638 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
3739 testing = True ,
3840 args = {'keyword' : {'general' : 'IOp(1/12=5,3/44=0)' }},
@@ -44,7 +46,7 @@ def setUpClass(cls):
4446 solvation_method = 'SMD' ,
4547 solvent = 'Water' ),
4648 project = 'test' ,
47- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
49+ project_directory = cls . project_directory ,
4850 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 ),
4951 ARCSpecies (label = 'spc2' , xyz = ['O 0 0 2' ], multiplicity = 3 )],
5052 testing = True ,
@@ -56,7 +58,7 @@ def setUpClass(cls):
5658 solvation_method = 'SMD' ,
5759 solvent = 'Water' ),
5860 project = 'test' ,
59- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
61+ project_directory = cls . project_directory ,
6062 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
6163 testing = True ,
6264 )
@@ -76,7 +78,7 @@ def setUpClass(cls):
7678 level = Level (method = 'wb97xd' ,
7779 basis = 'def2-TZVP' ),
7880 project = 'test' ,
79- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
81+ project_directory = cls . project_directory ,
8082 species = [spc_4 ],
8183 rotor_index = 0 ,
8284 testing = True ,
@@ -87,7 +89,7 @@ def setUpClass(cls):
8789 level = Level (method = 'wb97xd' ,
8890 basis = 'def2-TZVP' ),
8991 project = 'test' ,
90- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
92+ project_directory = cls . project_directory ,
9193 species = [ARCSpecies (label = 'birad singlet' ,
9294 xyz = ['O 0 0 1' ],
9395 multiplicity = 1 ,
@@ -99,7 +101,7 @@ def setUpClass(cls):
99101 level = Level (method = 'wb97xd' ,
100102 basis = 'def2-TZVP' ),
101103 project = 'test' ,
102- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
104+ project_directory = cls . project_directory ,
103105 species = [ARCSpecies (label = 'anion' , xyz = ['O 0 0 1' ], charge = - 1 , is_ts = False )],
104106 testing = True ,
105107 )
@@ -108,7 +110,7 @@ def setUpClass(cls):
108110 level = Level (method = 'wb97xd' ,
109111 basis = 'def2-TZVP' ),
110112 project = 'test' ,
111- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
113+ project_directory = cls . project_directory ,
112114 species = [ARCSpecies (label = 'IRC' , xyz = ['O 0 0 1' ], is_ts = True , multiplicity = 3 )],
113115 irc_direction = 'reverse' ,
114116 testing = True ,
@@ -117,7 +119,7 @@ def setUpClass(cls):
117119 job_type = 'composite' ,
118120 level = Level (method = 'cbs-qb3-paraskevas' ),
119121 project = 'test' ,
120- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
122+ project_directory = cls . project_directory ,
121123 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
122124 testing = True ,
123125 args = {'keyword' : {'general' : 'IOp(1/12=5,3/44=0)' }},
@@ -127,7 +129,7 @@ def setUpClass(cls):
127129 level = Level (method = 'wb97xd' ,
128130 basis = 'def2-TZVP' ),
129131 project = 'test' ,
130- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
132+ project_directory = cls . project_directory ,
131133 species = [ARCSpecies (label = 'anion' , xyz = ['O 0 0 1' ], charge = - 1 , is_ts = False )],
132134 testing = True ,
133135 )
@@ -136,7 +138,7 @@ def setUpClass(cls):
136138 level = Level (method = 'wb97xd' ),
137139 fine = True ,
138140 project = 'test' ,
139- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
141+ project_directory = cls . project_directory ,
140142 species = [ARCSpecies (label = 'anion' , xyz = ['O 0 0 1' ], charge = - 1 , is_ts = False )],
141143 testing = True ,
142144 args = {'trsh' : {'trsh' : ['int=(Acc2E=14)' ]}},
@@ -145,7 +147,7 @@ def setUpClass(cls):
145147 job_type = 'opt' ,
146148 level = Level (method = 'uff' ),
147149 project = 'test' ,
148- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
150+ project_directory = cls . project_directory ,
149151 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
150152 testing = True ,
151153 )
@@ -156,7 +158,7 @@ def setUpClass(cls):
156158 solvation_method = 'SMD' ,
157159 solvent = 'Water' ),
158160 project = 'test' ,
159- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
161+ project_directory = cls . project_directory ,
160162 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multi_species = 'mltspc1' , multiplicity = 3 ),
161163 ARCSpecies (label = 'spc2' , xyz = ['O 0 0 2' ], multi_species = 'mltspc1' , multiplicity = 3 ),
162164 ARCSpecies (label = 'ethanol' , xyz = ["""C 1.1658210 -0.4043550 0.0000000
@@ -212,7 +214,7 @@ def setUpClass(cls):
212214 fine = True ,
213215 ess_trsh_methods = ess_trsh_methods ,
214216 project = 'test' ,
215- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
217+ project_directory = cls . project_directory ,
216218 species = [spc_11 ],
217219 testing = True ,
218220 args = args
@@ -234,7 +236,7 @@ def setUpClass(cls):
234236 fine = True ,
235237 ess_trsh_methods = ess_trsh_methods ,
236238 project = 'test' ,
237- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
239+ project_directory = cls . project_directory ,
238240 species = [spc_11 ],
239241 testing = True ,
240242 args = args
@@ -256,7 +258,7 @@ def setUpClass(cls):
256258 fine = True ,
257259 ess_trsh_methods = ess_trsh_methods ,
258260 project = 'test' ,
259- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
261+ project_directory = cls . project_directory ,
260262 species = [spc_11 ],
261263 testing = True ,
262264 args = args
@@ -278,7 +280,7 @@ def setUpClass(cls):
278280 fine = True ,
279281 ess_trsh_methods = ess_trsh_methods ,
280282 project = 'test' ,
281- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
283+ project_directory = cls . project_directory ,
282284 species = [spc_11 ],
283285 testing = True ,
284286 args = args
@@ -301,7 +303,7 @@ def setUpClass(cls):
301303 fine = True ,
302304 ess_trsh_methods = ess_trsh_methods ,
303305 project = 'test' ,
304- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
306+ project_directory = cls . project_directory ,
305307 species = [spc_11 ],
306308 testing = True ,
307309 args = args
@@ -323,7 +325,7 @@ def setUpClass(cls):
323325 fine = True ,
324326 ess_trsh_methods = ess_trsh_methods ,
325327 project = 'test' ,
326- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
328+ project_directory = cls . project_directory ,
327329 species = [spc_11 ],
328330 testing = True ,
329331 args = args
@@ -346,7 +348,7 @@ def setUpClass(cls):
346348 fine = True ,
347349 ess_trsh_methods = ess_trsh_methods ,
348350 project = 'test' ,
349- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
351+ project_directory = cls . project_directory ,
350352 species = [spc_11 ],
351353 testing = True ,
352354 args = args
@@ -368,7 +370,7 @@ def setUpClass(cls):
368370 fine = True ,
369371 ess_trsh_methods = ess_trsh_methods ,
370372 project = 'test' ,
371- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
373+ project_directory = cls . project_directory ,
372374 species = [spc_11 ],
373375 testing = True ,
374376 args = args
@@ -390,7 +392,7 @@ def setUpClass(cls):
390392 fine = True ,
391393 ess_trsh_methods = ess_trsh_methods ,
392394 project = 'test' ,
393- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
395+ project_directory = cls . project_directory ,
394396 species = [spc_11 ],
395397 testing = True ,
396398 args = args
@@ -412,7 +414,7 @@ def setUpClass(cls):
412414 fine = True ,
413415 ess_trsh_methods = ess_trsh_methods ,
414416 project = 'test' ,
415- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
417+ project_directory = cls . project_directory ,
416418 species = [spc_11 ],
417419 testing = True ,
418420 args = args
@@ -434,7 +436,7 @@ def setUpClass(cls):
434436 fine = True ,
435437 ess_trsh_methods = ess_trsh_methods ,
436438 project = 'test' ,
437- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
439+ project_directory = cls . project_directory ,
438440 species = [spc_11 ],
439441 testing = True ,
440442 args = args
@@ -457,7 +459,7 @@ def setUpClass(cls):
457459 fine = True ,
458460 ess_trsh_methods = ess_trsh_methods ,
459461 project = 'test' ,
460- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
462+ project_directory = cls . project_directory ,
461463 species = [spc_11 ],
462464 testing = True ,
463465 args = args
@@ -480,7 +482,7 @@ def setUpClass(cls):
480482 fine = True ,
481483 ess_trsh_methods = ess_trsh_methods ,
482484 project = 'test' ,
483- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
485+ project_directory = cls . project_directory ,
484486 species = [spc_11 ],
485487 testing = True ,
486488 args = args
@@ -504,7 +506,7 @@ def setUpClass(cls):
504506 fine = True ,
505507 ess_trsh_methods = ess_trsh_methods ,
506508 project = 'test' ,
507- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
509+ project_directory = cls . project_directory ,
508510 species = [spc_11 ],
509511 testing = True ,
510512 args = args
@@ -537,7 +539,7 @@ def test_set_input_file_memory_with_headroom_marker(self):
537539 job_type = 'opt' ,
538540 level = Level (method = 'wb97xd' , basis = 'def2tzvp' ),
539541 project = 'test' ,
540- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
542+ project_directory = self . project_directory ,
541543 species = [ARCSpecies (label = 'spc_headroom' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
542544 testing = True ,
543545 ess_trsh_methods = ess_trsh_methods ,
@@ -553,7 +555,7 @@ def test_memory_headroom_marker_not_in_trsh_keyword(self):
553555 job_type = 'opt' ,
554556 level = Level (method = 'wb97xd' , basis = 'def2tzvp' ),
555557 project = 'test' ,
556- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
558+ project_directory = self . project_directory ,
557559 species = [ARCSpecies (label = 'spc_headroom_marker' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
558560 testing = True ,
559561 ess_trsh_methods = ['memory_headroom_0.6' ],
@@ -1214,7 +1216,7 @@ def test_user_keyword_args_survive_a_level_round_trip(self):
12141216 job_type = 'opt' ,
12151217 level = rebuilt_level ,
12161218 project = 'test' ,
1217- project_directory = os . path . join ( ARC_TESTING_PATH , 'test_GaussianAdapter' ) ,
1219+ project_directory = self . project_directory ,
12181220 species = [ARCSpecies (label = 'spc1' , xyz = ['O 0 0 1' ], multiplicity = 3 )],
12191221 testing = True ,
12201222 )
@@ -1225,14 +1227,6 @@ def test_user_keyword_args_survive_a_level_round_trip(self):
12251227 self .assertEqual (len (route_section ), 1 )
12261228 self .assertIn ('verytight' , route_section [0 ])
12271229
1228- @classmethod
1229- def tearDownClass (cls ):
1230- """
1231- A function that is run ONCE after all unit tests in this class.
1232- Delete all project directories created during these unit tests.
1233- """
1234- shutil .rmtree (os .path .join (ARC_TESTING_PATH , 'test_GaussianAdapter' ), ignore_errors = True )
1235-
12361230
12371231class TestGetMemoryHeadroomFraction (unittest .TestCase ):
12381232 """
0 commit comments