Skip to content

Commit 50824bb

Browse files
author
SentienceDEV
committed
fix tests2
1 parent bcb85c8 commit 50824bb

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,48 @@ jobs:
114114
run: |
115115
echo "=== Final check before tests ==="
116116
python << 'EOF'
117-
from sentience.agent_runtime import AgentRuntime
118-
import inspect
119-
120-
source = inspect.getsource(AgentRuntime.assert_done)
121-
print('assert_done source:')
122-
print(source)
123-
124-
# Check for problematic patterns: self.assertTrue( or assertTrue( without self.
125-
# But allow self.assertTrue as a method name if it exists
126117
import re
127118
128-
# Pattern 1: self.assertTrue( - this is the bug we're checking for
129-
if re.search(r'self\.assertTrue\s*\(', source):
130-
print('ERROR: Found self.assertTrue( - should be self.assert_( instead!')
131-
exit(1)
119+
# Check the source file directly (not the installed package)
120+
# This ensures we're checking what's actually in the repo
121+
with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f:
122+
content = f.read()
132123
133-
# Pattern 2: assertTrue( without self. - unittest style (also wrong)
134-
if re.search(r'(?<!self\.)assertTrue\s*\(', source):
135-
print('ERROR: Found assertTrue( without self. - should use self.assert_( instead!')
136-
exit(1)
124+
# Find assert_done method - look for the method definition and its body
125+
# Match from "def assert_done" until the next method/class at same indentation level
126+
assert_done_pattern = r'def assert_done\([^)]*\):.*?(?=\n def |\nclass |\Z)'
127+
assert_done_match = re.search(assert_done_pattern, content, re.DOTALL)
137128
138-
# Pattern 3: Check that assert_ is used correctly
139-
if 'self.assert_(' in source:
140-
print('OK: self.assert_ is used correctly')
129+
if assert_done_match:
130+
assert_done_source = assert_done_match.group(0)
131+
print('assert_done method found')
132+
133+
# Check for problematic patterns
134+
# Pattern 1: self.assertTrue( - this is the bug we're checking for
135+
if re.search(r'self\.assertTrue\s*\(', assert_done_source):
136+
print('ERROR: Found self.assertTrue( - should be self.assert_( instead!')
137+
print('\nassert_done source:')
138+
print(assert_done_source)
139+
exit(1)
140+
141+
# Pattern 2: Check that assert_ is used correctly
142+
if 'self.assert_(' in assert_done_source:
143+
print('OK: self.assert_ is used correctly in assert_done')
144+
else:
145+
print('WARNING: self.assert_( not found in assert_done')
146+
print('\nassert_done source:')
147+
print(assert_done_source)
148+
exit(1)
141149
else:
142-
print('WARNING: self.assert_( not found in assert_done')
150+
# Fallback: check entire file for the problematic pattern
151+
print('Could not isolate assert_done method, checking entire file...')
152+
if re.search(r'self\.assertTrue\s*\(', content):
153+
print('ERROR: Found self.assertTrue( in agent_runtime.py - should be self.assert_( instead!')
154+
exit(1)
155+
if 'self.assert_(' in content:
156+
print('OK: self.assert_ is used in agent_runtime.py')
157+
else:
158+
print('WARNING: Could not verify assert_ usage')
143159
EOF
144160
145161
- name: Run tests

0 commit comments

Comments
 (0)