Skip to content
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
14 changes: 14 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Publish to PyPI

on:
Expand Down
7 changes: 7 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Gemini CLI Instructions for terraform-python-testing-helper

- **Git Workflow:** Never use `git commit --amend`. Always create a new commit and push to the same branch to update an existing Pull Request.
- **File Editing:** Always use the `replace` tool (or `write_file` for new files) for file edits. Do NOT use shell heredocs (`cat << 'EOF'`) or inline Python scripts to modify files.
- **Copyright Boilerplate:** All new files must include the Apache 2.0 license boilerplate at the top. Ensure the copyright year is current (e.g., 2026).
- **Linting:** Always run the project's linters before committing changes. Specifically, check formatting with `yapf --diff --recursive --parallel *.py test` and verify license headers with `python3 .github/workflows/scripts/check_boilerplate.py .`.
- **Regressions & Testing:** When fixing a regression, fix it at the source library level. Do not modify the caller's code to work around the issue. Always create a reliable test case that reproduces the error before implementing the fix.
32 changes: 32 additions & 0 deletions test/test_tfdir_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import tempfile
from pathlib import Path
import tftest


def test_tfdir_as_path():
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir_path = Path(tmpdir).resolve()
tf = tftest.TerraformTest(tmpdir_path)
# The regression: tf.tfdir / 'something' throws TypeError
# if tf.tfdir is converted to a string.
assert (tf.tfdir / 'something') == tmpdir_path / 'something'


def test_tfdir_as_str():
with tempfile.TemporaryDirectory() as tmpdir:
tf = tftest.TerraformTest(tmpdir)
assert isinstance(tf.tfdir, str)
4 changes: 2 additions & 2 deletions tftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def _abspath(self, path):
"""Make relative path absolute from base dir."""
path_obj = Path(path)
if path_obj.is_absolute():
return str(path_obj)
return path
return str(Path(self._basedir) / path)

def _dirhash(self, directory, hash, ignore_hidden=False,
Expand Down Expand Up @@ -429,7 +429,7 @@ def cache(self, **kwargs):
return func(self, **kwargs)

cache_dir = self.cache_dir / \
Path(sha1(self.tfdir.encode("cp037")).hexdigest()) / \
Path(sha1(str(self.tfdir).encode("cp037")).hexdigest()) / \
Path(func.__name__)
cache_dir.mkdir(parents=True, exist_ok=True)

Expand Down
Loading