Skip to content

Commit

Permalink
add test for debugging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
BluemlJ committed Dec 3, 2024
1 parent d7805e7 commit a965d72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ jobs:
if: always() # Run general tests regardless of specific files changing
run: pytest tests/0_general/*


- name: Determine Changed Files
id: changes
run: |
git fetch origin ${{ github.event.before }} --depth=1
git diff --name-only ${{ github.event.before }} ${{ github.sha }} > changed_files.txt
cat changed_files.txt
CHANGED_PYFILES=$(git diff --name-only --diff-filter=ACMRT HEAD | grep '\.py$')
- name: Test for Debugging Strings
run: pytest tests/test_no_debugging.py

- name: Set Games to Test
id: set_games
Expand Down
17 changes: 17 additions & 0 deletions tests/test_no_debugging_statements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

@pytest.fixture
def source_files(request):
files = request.config.getoption("--file_path")
return files.split()

def pytest_addoption(parser):
parser.addoption("--file_path", action="store", default="")

@pytest.mark.parametrize("file_path", source_files())
def test_no_debugging_statements(file_path):
with open(file_path, "r") as f:
lines = f.readlines()
for i, line in enumerate(lines):
if "ipdb.set_trace()" in line or "print(" in line:
pytest.fail(f"Debugging statement found in {file_path} at line {i + 1}: {line.strip()}")

0 comments on commit a965d72

Please sign in to comment.