33import os
44import numpy as np
55import flopy
6+ from ci_framework import baseTestDir , flopyTest
67
7- cpth = os .path .join ("temp" , "t017" )
8- # make the directory if it does not exists
9- if not os .path .isdir (cpth ):
10- os .makedirs (cpth , exist_ok = True )
8+ baseDir = baseTestDir (__file__ , relPath = "temp" , verbose = True )
119
1210
1311def test_formattedfile_read ():
12+ model_ws = f"{ baseDir } _test_formattedfile_read"
13+ testFramework = flopyTest (verbose = True , testDirs = model_ws , create = True )
1414
1515 h = flopy .utils .FormattedHeadFile (
1616 os .path .join (".." , "examples" , "data" , "mf2005_test" , "test1tr.githds" )
@@ -41,7 +41,7 @@ def test_formattedfile_read():
4141 h .close ()
4242
4343 # Check error when reading empty file
44- fname = os .path .join (cpth , "empty.githds" )
44+ fname = os .path .join (model_ws , "empty.githds" )
4545 with open (fname , "w" ):
4646 pass
4747 with pytest .raises (ValueError ):
@@ -51,6 +51,8 @@ def test_formattedfile_read():
5151
5252
5353def test_binaryfile_read ():
54+ model_ws = f"{ baseDir } _test_binaryfile_read"
55+ testFramework = flopyTest (verbose = True , testDirs = model_ws , create = True )
5456
5557 h = flopy .utils .HeadFile (
5658 os .path .join (".." , "examples" , "data" , "freyberg" , "freyberg.githds" )
@@ -81,7 +83,7 @@ def test_binaryfile_read():
8183 h .close ()
8284
8385 # Check error when reading empty file
84- fname = os .path .join (cpth , "empty.githds" )
86+ fname = os .path .join (model_ws , "empty.githds" )
8587 with open (fname , "w" ):
8688 pass
8789 with pytest .raises (ValueError ):
@@ -148,6 +150,8 @@ def test_cellbudgetfile_read():
148150
149151
150152def test_cellbudgetfile_position ():
153+ model_ws = f"{ baseDir } _test_cellbudgetfile_position"
154+ testFramework = flopyTest (verbose = True , testDirs = model_ws , create = True )
151155
152156 fpth = os .path .join (
153157 ".." , "examples" , "data" , "zonbud_examples" , "freyberg.gitcbc"
@@ -176,7 +180,7 @@ def test_cellbudgetfile_position():
176180 length = os .path .getsize (fpth ) - ipos
177181
178182 buffsize = 32
179- opth = os .path .join (cpth , "end.cbc" )
183+ opth = os .path .join (model_ws , "end.cbc" )
180184 with open (opth , "wb" ) as fout :
181185 while length :
182186 chunk = min (buffsize , length )
@@ -204,7 +208,7 @@ def test_cellbudgetfile_position():
204208 assert np .array_equal (d1 , d2 ), msg
205209
206210 # Check error when reading empty file
207- fname = os .path .join (cpth , "empty.gitcbc" )
211+ fname = os .path .join (model_ws , "empty.gitcbc" )
208212 with open (fname , "w" ):
209213 pass
210214 with pytest .raises (ValueError ):
@@ -324,12 +328,14 @@ def test_cellbudgetfile_readrecord_waux():
324328
325329
326330def test_binaryfile_writeread ():
331+ model_ws = f"{ baseDir } _test_binaryfile_writeread"
332+ testFramework = flopyTest (verbose = True , testDirs = model_ws , create = True )
327333
328334 pth = os .path .join (".." , "examples" , "data" , "nwt_test" )
329335 model = "Pr3_MFNWT_lower.nam"
330336 ml = flopy .modflow .Modflow .load (model , version = "mfnwt" , model_ws = pth )
331337 # change the model work space
332- ml .change_model_ws (os . path . join ( "temp" , "t017" ) )
338+ ml .change_model_ws (model_ws )
333339 #
334340 ncol = ml .dis .ncol
335341 nrow = ml .dis .nrow
@@ -350,7 +356,7 @@ def test_binaryfile_writeread():
350356 kper = 1 ,
351357 )
352358 b = ml .dis .botm .array [0 , :, :].astype (np .float64 )
353- pth = os .path .join ("temp" , "t017" , "bottom.hds" )
359+ pth = os .path .join (model_ws , "bottom.hds" )
354360 flopy .utils .Util2d .write_bin (b .shape , pth , b , header_data = header )
355361
356362 bo = flopy .utils .HeadFile (pth , precision = precision )
@@ -380,7 +386,7 @@ def test_binaryfile_writeread():
380386 kper = 1 ,
381387 )
382388 b = ml .dis .botm .array [0 , :, :].astype (np .float32 )
383- pth = os .path .join ("temp" , "t017" , "bottom_single.hds" )
389+ pth = os .path .join (model_ws , "bottom_single.hds" )
384390 flopy .utils .Util2d .write_bin (b .shape , pth , b , header_data = header )
385391
386392 bo = flopy .utils .HeadFile (pth , precision = precision )
0 commit comments