@@ -381,27 +381,27 @@ def test_write_json_output(self, request_output: RequestOutput, tmp_cwd: Path):
381
381
assert written_output == request_output
382
382
383
383
384
+ def env_file_as_json (for_output_dir : Path ) -> str :
385
+ gocache = f'{{"name": "GOCACHE", "value": "{ for_output_dir } /deps/gomod"}}'
386
+ gosumdb = '{"name": "GOSUMDB", "value": "off"}'
387
+ return f"[{ gocache } , { gosumdb } ]\n "
388
+
389
+
390
+ def env_file_as_env (for_output_dir : Path ) -> str :
391
+ return dedent (
392
+ f"""
393
+ export GOCACHE={ for_output_dir } /deps/gomod
394
+ export GOSUMDB=off
395
+ """
396
+ ).lstrip ()
397
+
398
+
384
399
class TestGenerateEnv :
385
400
ENV_VARS = [
386
401
{"name" : "GOCACHE" , "value" : "deps/gomod" , "kind" : "path" },
387
402
{"name" : "GOSUMDB" , "value" : "off" , "kind" : "literal" },
388
403
]
389
404
390
- @staticmethod
391
- def env_file_as_json (for_output_dir : Path ) -> str :
392
- gocache = f'{{"name": "GOCACHE", "value": "{ for_output_dir } /deps/gomod"}}'
393
- gosumdb = '{"name": "GOSUMDB", "value": "off"}'
394
- return f"[{ gocache } , { gosumdb } ]\n "
395
-
396
- @staticmethod
397
- def env_file_as_env (for_output_dir : Path ) -> str :
398
- return dedent (
399
- f"""
400
- export GOCACHE={ for_output_dir } /deps/gomod
401
- export GOSUMDB=off
402
- """
403
- ).lstrip ()
404
-
405
405
@pytest .fixture
406
406
def tmp_cwd_as_output_dir (self , tmp_cwd : Path ) -> Path :
407
407
"""Change working directory to a tmpdir and write output.json into it."""
@@ -463,9 +463,9 @@ def test_generate_for_different_output_dir(
463
463
464
464
resolved_output_dir = Path (expect_output_dir .format (cwd = tmp_cwd_as_output_dir ))
465
465
if fmt == "env" :
466
- expect_output = self . env_file_as_env (resolved_output_dir )
466
+ expect_output = env_file_as_env (resolved_output_dir )
467
467
else :
468
- expect_output = self . env_file_as_json (resolved_output_dir )
468
+ expect_output = env_file_as_json (resolved_output_dir )
469
469
470
470
assert result .stdout == expect_output
471
471
0 commit comments