Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

releng - switch to ruff and update dependencies #71

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
python-version: "3.10"
- name: Linting
run: |
pip install pre-commit
pre-commit run --all-files
pip install ruff
ruff check pytest_terraform tests

Tests:
needs: Lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11"]
python-version: [3.9, "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
20 changes: 0 additions & 20 deletions .pre-commit-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


lint:
pre-commit run --all-files
ruff check pytest_terraform tests

coverage:
coverage run --source pytest_terraform -m pytest tests
Expand Down
713 changes: 116 additions & 597 deletions poetry.lock

Large diffs are not rendered by default.

46 changes: 7 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,26 @@ classifiers=[
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.7,<4.0"
pytest = ">= 6.0"
python = ">=3.8,<4.0"
pytest = ">= 7.0"
jmespath = ">= 0.10.0"
portalocker = ">= 1.7.0"
pytest-xdist = ">= 1.31.0"

[tool.poetry.dev-dependencies]
black = ">=19.10b0"
isort = ">=4.3.21"
flake8 = ">=3.7.9"
coverage = ">=6.1"
pytest-cov = ">=2.8.1"
pre-commit = ">=2.9.2"

[tool.poetry.plugins.pytest11]
terraform = "pytest_terraform.plugin"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.4.4"
pytest-cov = ">=2.8.1"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
norecursedirs = ["data", "terraform"]

[tool.isort]
line_length = 90
force_single_line = true
atomic = true
include_trailing_comma = true
lines_after_imports = 2
lines_between_types = 1
multi_line_output = 3
use_parentheses = true
not_skip = "__init__.py"
skip_glob = ["*/setup.py", "*tf", "*md"]
filter_files = true

known_first_party = "poetry"

[tool.black]
[tool.ruff]
line-length = 90
exclude = '''
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
| _build
| build
| dist
| tests/.*/setup.py
)/
'''

[build-system]
requires = ["poetry>=0.12"]
Expand Down
14 changes: 10 additions & 4 deletions pytest_terraform/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def __init__(
self.module_dir = module_dir
# use parent dir of work/data dir to avoid
# https://github.com/hashicorp/terraform/issues/22999
self.state_path = state_path or os.path.join(work_dir, "..", "terraform.tfstate")
self.state_path = state_path or os.path.join(
work_dir, "..", "terraform.tfstate"
)
self.stream_output = stream_output
self.plugin_cache = plugin_cache or ""
self.tf_bin = tf_bin
Expand Down Expand Up @@ -248,7 +250,7 @@ def update(self, state: Union[TerraformStateJson, str]):

@staticmethod
def parse_state(
state: Union[TerraformStateJson, str]
state: Union[TerraformStateJson, str],
) -> Tuple[Dict[str, any], Dict[str, Any]]:
"""extract resources and outputs from state

Expand Down Expand Up @@ -383,7 +385,9 @@ def resolve_module_dir(self):
self.test_dir.dirpath().join("terraform", self.tf_root_module),
]
if LazyModuleDir.resolve():
candidates.insert(0, local(LazyModuleDir.resolve()).join(self.tf_root_module))
candidates.insert(
0, local(LazyModuleDir.resolve()).join(self.tf_root_module)
)
for candidate in candidates:
if not candidate.check(exists=1, dir=1):
continue
Expand All @@ -409,7 +413,9 @@ def __call__(self, request, tmpdir_factory, worker_id):
return TerraformTestApi.from_file(
os.path.join(module_dir, "tf_resources.json")
)
work_dir = tmpdir_factory.mktemp(self.tf_root_module, numbered=True).join("work")
work_dir = tmpdir_factory.mktemp(self.tf_root_module, numbered=True).join(
"work"
)
self.runner = self.get_runner(module_dir, work_dir)
return self.create(request, module_dir)

Expand Down
33 changes: 0 additions & 33 deletions tests/test_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,39 +231,6 @@ def test_help_message(testdir):
result.stdout.fnmatch_lines(["terraform:", ("*--tf-binary=DEST_TF_BINARY*")])


def test_plugins_ini_setting(testdir):
testdir.makeini(
"""
[pytest]
terraform-plugins =
aws ~> 2.2.0
github
"""
)

testdir.makepyfile(
"""
import pytest

@pytest.fixture
def hello(request):
return request.config.getini('terraform-mod-dir')

def test_hello_world(hello):
assert hello == ''
return
"""
)

result = testdir.runpytest("-v", "-s")

# fnmatch_lines does an assertion internally
result.stdout.fnmatch_lines(["*::test_hello_world PASSED*"])

# make sure that that we get a '0' exit code for the testsuite
assert result.ret == 0


@pytest.mark.skipif(not shutil.which("terraform"), reason="Terraform binary missing")
def test_plugins_ini_setting_terraform_mod_dir(testdir):
mod_dir = Path(__file__).parent / "data" / "mrofarret"
Expand Down
Loading