(renderedValue: string)
| 5 | import type { AssertionParams, GradingResult } from '../types/index'; |
| 6 | |
| 7 | function buildPythonScript(renderedValue: string): string { |
| 8 | const isMultiline = renderedValue.includes('\n'); |
| 9 | let indentStyle = ' '; |
| 10 | if (isMultiline) { |
| 11 | // Detect the indentation style of the first indented line. |
| 12 | const match = renderedValue.match(/^(?!\s*$)\s+/m); |
| 13 | if (match) { |
| 14 | indentStyle = match[0]; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | return `import json |
| 19 | |
| 20 | def main(output, context): |
| 21 | ${ |
| 22 | isMultiline |
| 23 | ? renderedValue |
| 24 | .split('\n') |
| 25 | .map((line) => `${indentStyle}${line}`) |
| 26 | .join('\n') |
| 27 | : ` return ${renderedValue}` |
| 28 | } |
| 29 | `; |
| 30 | } |
| 31 | |
| 32 | export const handlePython = async ({ |
| 33 | assertion, |
no test coverage detected
searching dependent graphs…