Path: blob/main/extensions/copilot/src/platform/parser/test/node/getStructure.py.spec.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { afterAll, describe, expect, test } from 'vitest';6import { _dispose } from '../../node/parserImpl';7import { WASMLanguage } from '../../node/treeSitterLanguages';8import { fromFixture, snapshotPathInFixture, srcWithAnnotatedStructure } from './getStructure.util';910describe('getStructure - python', () => {1112afterAll(() => _dispose());1314function pySrcWithStructure(source: string) {15return srcWithAnnotatedStructure(WASMLanguage.Python, source);16}1718test('py source with different syntax constructs', async () => {1920const source = await fromFixture('test.py');2122expect(await pySrcWithStructure(source)).toMatchSnapshot();23});2425test('try-catch block', async () => {2627const file = 'try.py';2829const source = await fromFixture(file);3031await expect(await pySrcWithStructure(source)).toMatchFileSnapshot(snapshotPathInFixture(file));32});33});343536