Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/parser/test/node/getStructure.py.spec.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { afterAll, describe, expect, test } from 'vitest';
7
import { _dispose } from '../../node/parserImpl';
8
import { WASMLanguage } from '../../node/treeSitterLanguages';
9
import { fromFixture, snapshotPathInFixture, srcWithAnnotatedStructure } from './getStructure.util';
10
11
describe('getStructure - python', () => {
12
13
afterAll(() => _dispose());
14
15
function pySrcWithStructure(source: string) {
16
return srcWithAnnotatedStructure(WASMLanguage.Python, source);
17
}
18
19
test('py source with different syntax constructs', async () => {
20
21
const source = await fromFixture('test.py');
22
23
expect(await pySrcWithStructure(source)).toMatchSnapshot();
24
});
25
26
test('try-catch block', async () => {
27
28
const file = 'try.py';
29
30
const source = await fromFixture(file);
31
32
await expect(await pySrcWithStructure(source)).toMatchFileSnapshot(snapshotPathInFixture(file));
33
});
34
});
35
36