Skip to content

Commit 822250d

Browse files
committed
Fix tests to run on python3.9
staticmethods are not directly callable in python < 3.10: python/cpython#87848 Signed-off-by: Adam Cmiel <acmiel@redhat.com>
1 parent e2925aa commit 822250d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/unit/test_cli.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -381,27 +381,27 @@ def test_write_json_output(self, request_output: RequestOutput, tmp_cwd: Path):
381381
assert written_output == request_output
382382

383383

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+
384399
class TestGenerateEnv:
385400
ENV_VARS = [
386401
{"name": "GOCACHE", "value": "deps/gomod", "kind": "path"},
387402
{"name": "GOSUMDB", "value": "off", "kind": "literal"},
388403
]
389404

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-
405405
@pytest.fixture
406406
def tmp_cwd_as_output_dir(self, tmp_cwd: Path) -> Path:
407407
"""Change working directory to a tmpdir and write output.json into it."""
@@ -463,9 +463,9 @@ def test_generate_for_different_output_dir(
463463

464464
resolved_output_dir = Path(expect_output_dir.format(cwd=tmp_cwd_as_output_dir))
465465
if fmt == "env":
466-
expect_output = self.env_file_as_env(resolved_output_dir)
466+
expect_output = env_file_as_env(resolved_output_dir)
467467
else:
468-
expect_output = self.env_file_as_json(resolved_output_dir)
468+
expect_output = env_file_as_json(resolved_output_dir)
469469

470470
assert result.stdout == expect_output
471471

0 commit comments

Comments
 (0)