43
43
from hashlib import sha1
44
44
import inspect
45
45
46
- __version__ = '1.7.3 '
46
+ __version__ = '1.7.4 '
47
47
48
48
_LOGGER = logging .getLogger ('tftest' )
49
49
@@ -315,7 +315,8 @@ class TerraformTest(object):
315
315
the directory of the python file that instantiates this class
316
316
"""
317
317
318
- def __init__ (self , tfdir , basedir = None , binary = 'terraform' , env = None , enable_cache = False , cache_dir = None ):
318
+ def __init__ (self , tfdir , basedir = None , binary = 'terraform' , env = None ,
319
+ enable_cache = False , cache_dir = None ):
319
320
"""Set Terraform folder to operate on, and optional base directory."""
320
321
self ._basedir = basedir or os .getcwd ()
321
322
self .binary = binary
@@ -376,6 +377,7 @@ def _abspath(self, path):
376
377
return path if os .path .isabs (path ) else os .path .join (self ._basedir , path )
377
378
378
379
def _cache (func ):
380
+
379
381
def cache (self , ** kwargs ):
380
382
"""
381
383
Runs the tftest instance method or retreives the cache value if it exists
@@ -399,8 +401,7 @@ def cache(self, **kwargs):
399
401
400
402
params = {
401
403
** {
402
- k : v
403
- for k , v in self .__dict__ .items ()
404
+ k : v for k , v in self .__dict__ .items ()
404
405
# only uses instance attributes that are involved in the results of
405
406
# the decorated method
406
407
if k in ["binary" , "_basedir" , "tfdir" , "env" ]
@@ -409,8 +410,8 @@ def cache(self, **kwargs):
409
410
}
410
411
411
412
hash_filename = sha1 (
412
- json .dumps (params , sort_keys = True , default = str ). encode ( "cp037" )
413
- ).hexdigest () + ".pickle"
413
+ json .dumps (params , sort_keys = True ,
414
+ default = str ). encode ( "cp037" ) ).hexdigest () + ".pickle"
414
415
415
416
cache_key = cache_dir / hash_filename
416
417
_LOGGER .debug ("Cache key: %s" , cache_key )
@@ -437,6 +438,7 @@ def cache(self, **kwargs):
437
438
pickle .dump (out , f , pickle .HIGHEST_PROTOCOL )
438
439
439
440
return out
441
+
440
442
return cache
441
443
442
444
@_cache
@@ -596,7 +598,8 @@ def apply(self, input=False, color=False, auto_approve=True, tf_vars=None,
596
598
return self .execute_command ('apply' , * cmd_args ).out
597
599
598
600
@_cache
599
- def output (self , name = None , color = False , json_format = True , use_cache = False , ** kw ):
601
+ def output (self , name = None , color = False , json_format = True , use_cache = False ,
602
+ ** kw ):
600
603
"""Run Terraform output command."""
601
604
cmd_args = []
602
605
if name :
@@ -715,8 +718,8 @@ def __init__(self, tfdir, basedir=None, binary='terragrunt', env=None,
715
718
cache_dir: optional base directory to use for caching, defaults to
716
719
the directory of the python file that instantiates this class
717
720
"""
718
- TerraformTest .__init__ (self , tfdir , basedir , binary ,
719
- env , enable_cache , cache_dir )
721
+ TerraformTest .__init__ (self , tfdir , basedir , binary , env , enable_cache ,
722
+ cache_dir )
720
723
self .tg_run_all = tg_run_all
721
724
if self .tg_run_all :
722
725
self ._plan_formatter = partial (_parse_run_all_out ,
0 commit comments