(body: string)
| 37 | `; |
| 38 | |
| 39 | async function targetsOf(body: string): Promise<string[]> { |
| 40 | const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-py-chain-')); |
| 41 | roots.push(root); |
| 42 | fs.writeFileSync(path.join(root, 'response.py'), RESPONSE); |
| 43 | fs.writeFileSync(path.join(root, 'use.py'), `from response import HttpResponse\n\n\ndef caller(self):\n ${body}\n`); |
| 44 | const cg = await CodeGraph.init(root, { index: true }); |
| 45 | graphs.push(cg); |
| 46 | const fn = cg.getNodesByName('caller')[0]!; |
| 47 | return cg.getOutgoingEdges(fn.id) |
| 48 | .filter((e) => e.kind === 'calls' || e.kind === 'instantiates') |
| 49 | .map((e) => `${e.kind} ${cg.getNode(e.target)!.qualifiedName}`); |
| 50 | } |
| 51 | |
| 52 | describe('a Python chain through an imported class', () => { |
| 53 | it.each([ |
no test coverage detected