Skip to content

Commit 3b350d4

Browse files
Fix code review issues: improve error handling and logic
Co-authored-by: thoughtparametersllc <194255310+thoughtparametersllc@users.noreply.github.com>
1 parent 62383ad commit 3b350d4

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

action.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ runs:
101101
fi
102102
103103
# Detect nose/nose2
104-
if [ -f ".noserc" ] || [ -f "nose.cfg" ] || [ -f "setup.cfg" ] && grep -q "\[nosetests\]" setup.cfg 2>/dev/null; then
104+
if [ -f ".noserc" ] || [ -f "nose.cfg" ] || ([ -f "setup.cfg" ] && grep -q "\[nosetests\]" setup.cfg 2>/dev/null); then
105105
echo "✓ nose2 detected"
106106
NOSE_DETECTED=true
107107
fi
@@ -297,8 +297,16 @@ runs:
297297
- name: Run doctest
298298
run: |
299299
echo "Running doctest..."
300-
python3 -m doctest -v $(find . -name "*.py" -not -path "./venv/*" -not -path "./.venv/*" -not -path "./build/*" -not -path "./dist/*") 2>&1 | tee doctest_output.txt
301-
echo "DOCTEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
300+
# Find Python files excluding common virtual environment and build directories
301+
PY_FILES=$(find . -name "*.py" -not -path "./venv/*" -not -path "./.venv/*" -not -path "./build/*" -not -path "./dist/*" -not -path "./.tox/*" -not -path "./node_modules/*" 2>/dev/null || true)
302+
303+
if [ -n "$PY_FILES" ]; then
304+
echo "$PY_FILES" | xargs python3 -m doctest -v 2>&1 | tee doctest_output.txt
305+
echo "DOCTEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
306+
else
307+
echo "No Python files found for doctest"
308+
echo "DOCTEST_EXIT_CODE=0" >> $GITHUB_ENV
309+
fi
302310
shell: bash
303311
if: env.DOCTEST_DETECTED == 'true'
304312
continue-on-error: true

examples/behave_example/features/steps/calculator_steps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def multiply(self, a, b):
2525

2626
def divide(self, a, b):
2727
"""Divide a by b."""
28+
if b == 0:
29+
raise ValueError("Cannot divide by zero")
2830
self.result = a / b
2931
return self.result
3032

0 commit comments

Comments
 (0)