Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/templates/new723ScriptTemplate/script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# /// script_name
# /// script
# requires-python = ">=X.XX" TODO: Update this to the minimum Python version you want to support
# dependencies = [
# TODO: Add any dependencies your script requires
Expand Down
44 changes: 44 additions & 0 deletions src/test/features/creators/newScriptProject.unit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import assert from 'assert';
import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';

// Path to the real script template, resolved from the compiled test location
// (out/test/features/creators/ → workspaceRoot/files/templates/...). We do NOT
// rely on `NEW_PROJECT_TEMPLATES_FOLDER` because it is anchored at
// `path.dirname(__dirname)` of the compiled `constants.js`, which resolves to
// `out/` in test mode and does not contain the bundled template tree.
const TEMPLATE_PATH = path.join(
__dirname,
'..',
'..',
'..',
'..',
'files',
'templates',
'new723ScriptTemplate',
'script.py',
);

suite('new723ScriptTemplate / NewScriptProject', () => {
let tmpDir: string;

setup(async () => {
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'new-script-test-'));
});

teardown(async () => {
await fs.remove(tmpDir);
});

test('Template file starts with a valid PEP 723 header (# /// script)', async () => {
const contents = await fs.readFile(TEMPLATE_PATH, 'utf8');
const firstNonBlankLine = contents.split(/\r?\n/).find((l) => l.trim().length > 0);

assert.strictEqual(
firstNonBlankLine,
'# /// script',
'Template must start with a valid PEP 723 `script` header line',
);
});
});
Loading