Skip to content

Commit afd968b

Browse files
authored
releng - switch to ruff and update dependencies (#71)
1 parent 6847de1 commit afd968b

File tree

8 files changed

+137
-710
lines changed

8 files changed

+137
-710
lines changed

.flake8

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
python-version: "3.10"
2121
- name: Linting
2222
run: |
23-
pip install pre-commit
24-
pre-commit run --all-files
23+
pip install ruff
24+
ruff check pytest_terraform tests
2525
2626
Tests:
2727
needs: Lint
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
python-version: [3.9, "3.10", "3.11"]
31+
python-version: [3.9, "3.10", "3.11", "3.12"]
3232
steps:
3333
- name: Checkout
3434
uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
lint:
4-
pre-commit run --all-files
4+
ruff check pytest_terraform tests
55

66
coverage:
77
coverage run --source pytest_terraform -m pytest tests

poetry.lock

Lines changed: 116 additions & 597 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,26 @@ classifiers=[
1212
readme = "README.md"
1313

1414
[tool.poetry.dependencies]
15-
python = ">=3.7,<4.0"
16-
pytest = ">= 6.0"
15+
python = ">=3.8,<4.0"
16+
pytest = ">= 7.0"
1717
jmespath = ">= 0.10.0"
1818
portalocker = ">= 1.7.0"
1919
pytest-xdist = ">= 1.31.0"
2020

21-
[tool.poetry.dev-dependencies]
22-
black = ">=19.10b0"
23-
isort = ">=4.3.21"
24-
flake8 = ">=3.7.9"
25-
coverage = ">=6.1"
26-
pytest-cov = ">=2.8.1"
27-
pre-commit = ">=2.9.2"
28-
2921
[tool.poetry.plugins.pytest11]
3022
terraform = "pytest_terraform.plugin"
3123

24+
[tool.poetry.group.dev.dependencies]
25+
ruff = ">=0.4.4"
26+
pytest-cov = ">=2.8.1"
27+
3228
[tool.pytest.ini_options]
3329
minversion = "6.0"
3430
testpaths = ["tests"]
3531
norecursedirs = ["data", "terraform"]
3632

37-
[tool.isort]
38-
line_length = 90
39-
force_single_line = true
40-
atomic = true
41-
include_trailing_comma = true
42-
lines_after_imports = 2
43-
lines_between_types = 1
44-
multi_line_output = 3
45-
use_parentheses = true
46-
not_skip = "__init__.py"
47-
skip_glob = ["*/setup.py", "*tf", "*md"]
48-
filter_files = true
49-
50-
known_first_party = "poetry"
51-
52-
[tool.black]
33+
[tool.ruff]
5334
line-length = 90
54-
exclude = '''
55-
/(
56-
\.eggs
57-
| \.git
58-
| \.mypy_cache
59-
| \.tox
60-
| \.venv
61-
| _build
62-
| build
63-
| dist
64-
| tests/.*/setup.py
65-
)/
66-
'''
6735

6836
[build-system]
6937
requires = ["poetry>=0.12"]

pytest_terraform/tf.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def __init__(
5555
self.module_dir = module_dir
5656
# use parent dir of work/data dir to avoid
5757
# https://github.com/hashicorp/terraform/issues/22999
58-
self.state_path = state_path or os.path.join(work_dir, "..", "terraform.tfstate")
58+
self.state_path = state_path or os.path.join(
59+
work_dir, "..", "terraform.tfstate"
60+
)
5961
self.stream_output = stream_output
6062
self.plugin_cache = plugin_cache or ""
6163
self.tf_bin = tf_bin
@@ -248,7 +250,7 @@ def update(self, state: Union[TerraformStateJson, str]):
248250

249251
@staticmethod
250252
def parse_state(
251-
state: Union[TerraformStateJson, str]
253+
state: Union[TerraformStateJson, str],
252254
) -> Tuple[Dict[str, any], Dict[str, Any]]:
253255
"""extract resources and outputs from state
254256
@@ -383,7 +385,9 @@ def resolve_module_dir(self):
383385
self.test_dir.dirpath().join("terraform", self.tf_root_module),
384386
]
385387
if LazyModuleDir.resolve():
386-
candidates.insert(0, local(LazyModuleDir.resolve()).join(self.tf_root_module))
388+
candidates.insert(
389+
0, local(LazyModuleDir.resolve()).join(self.tf_root_module)
390+
)
387391
for candidate in candidates:
388392
if not candidate.check(exists=1, dir=1):
389393
continue
@@ -409,7 +413,9 @@ def __call__(self, request, tmpdir_factory, worker_id):
409413
return TerraformTestApi.from_file(
410414
os.path.join(module_dir, "tf_resources.json")
411415
)
412-
work_dir = tmpdir_factory.mktemp(self.tf_root_module, numbered=True).join("work")
416+
work_dir = tmpdir_factory.mktemp(self.tf_root_module, numbered=True).join(
417+
"work"
418+
)
413419
self.runner = self.get_runner(module_dir, work_dir)
414420
return self.create(request, module_dir)
415421

tests/test_terraform.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -231,39 +231,6 @@ def test_help_message(testdir):
231231
result.stdout.fnmatch_lines(["terraform:", ("*--tf-binary=DEST_TF_BINARY*")])
232232

233233

234-
def test_plugins_ini_setting(testdir):
235-
testdir.makeini(
236-
"""
237-
[pytest]
238-
terraform-plugins =
239-
aws ~> 2.2.0
240-
github
241-
"""
242-
)
243-
244-
testdir.makepyfile(
245-
"""
246-
import pytest
247-
248-
@pytest.fixture
249-
def hello(request):
250-
return request.config.getini('terraform-mod-dir')
251-
252-
def test_hello_world(hello):
253-
assert hello == ''
254-
return
255-
"""
256-
)
257-
258-
result = testdir.runpytest("-v", "-s")
259-
260-
# fnmatch_lines does an assertion internally
261-
result.stdout.fnmatch_lines(["*::test_hello_world PASSED*"])
262-
263-
# make sure that that we get a '0' exit code for the testsuite
264-
assert result.ret == 0
265-
266-
267234
@pytest.mark.skipif(not shutil.which("terraform"), reason="Terraform binary missing")
268235
def test_plugins_ini_setting_terraform_mod_dir(testdir):
269236
mod_dir = Path(__file__).parent / "data" / "mrofarret"

0 commit comments

Comments
 (0)