Krishp1 commited on
Commit
7a9dbc6
·
verified ·
1 Parent(s): 26b1cee

Update nodes.py

Browse files
Files changed (1) hide show
  1. nodes.py +9 -7
nodes.py CHANGED
@@ -136,26 +136,28 @@ def test_generator(state: State):
136
 
137
  response = llm.invoke([
138
  SystemMessage(content="""You are a Python testing expert.
139
- Return ONLY runnable Python test code — no markdown, no backticks."""),
 
140
  HumanMessage(content=f"""
141
  Generate test cases for this code:
142
-
143
  TASK: {state['task']}
144
  CODE:
145
  {code}
146
 
147
  Rules:
148
- - Copy ALL function definitions inline — do NOT import from files
149
- - Cover: normal cases, edge cases, large input
150
- - Call each test function at the bottom to run them
151
- - Do NOT use unittest or sys just plain assert statements
152
- - Print "All tests passed!" at the end if successful
 
153
 
154
  Return ONLY runnable Python code:
155
  """)
156
  ])
157
 
158
  tests = response.content
 
159
  tests = re.sub(r"```python", "", tests)
160
  tests = re.sub(r"```", "", tests)
161
  tests = tests.strip()
 
136
 
137
  response = llm.invoke([
138
  SystemMessage(content="""You are a Python testing expert.
139
+ Return ONLY runnable Python test code — no markdown, no backticks.
140
+ DO NOT use 'unittest', 'pytest', or 'sys'."""),
141
  HumanMessage(content=f"""
142
  Generate test cases for this code:
 
143
  TASK: {state['task']}
144
  CODE:
145
  {code}
146
 
147
  Rules:
148
+ - Copy ALL function definitions inline.
149
+ - Use ONLY simple 'assert' statements for validation.
150
+ - Do NOT use 'unittest' or 'sys'.
151
+ - If a test fails, let the script raise an AssertionError.
152
+ - Print "All tests passed!" at the end if successful.
153
+ - Wrap all test calls in a 'try...except' block to print the error before exiting.
154
 
155
  Return ONLY runnable Python code:
156
  """)
157
  ])
158
 
159
  tests = response.content
160
+ # ... (keep existing regex cleaning)
161
  tests = re.sub(r"```python", "", tests)
162
  tests = re.sub(r"```", "", tests)
163
  tests = tests.strip()