Skip to content
Closed
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
26 changes: 26 additions & 0 deletions tests/repo/python-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ describe("pytest settings", () => {
});
});

describe("pytest settings from tox.ini and setup.cfg (#161)", () => {
it("reads python_files and testpaths from tox.ini [pytest], including a continued value", () => {
const tox = readPytestSettings((path) => path === "tox.ini"
? "[tox]\nenvlist = py312\n\n[pytest]\npython_files = check_*.py\n *_spec.py\ntestpaths = tests\n integration\n\n[testenv]\ncommands = pytest\n"
: undefined);
assert.deepEqual(tox, { pythonFiles: ["check_*.py", "*_spec.py"], testpaths: ["tests", "integration"], pythonpath: [] });
assert.ok(isPytestFile("integration/check_a.py", tox));
assert.ok(!isPytestFile("integration/test_a.py", tox));
});

it("reads the same keys from setup.cfg [tool:pytest]", () => {
const cfg = readPytestSettings((path) => path === "setup.cfg"
? "[metadata]\nname = x\n\n[tool:pytest]\npython_files = check_*.py\ntestpaths =\n tests\n integration\npythonpath = src\n"
: undefined);
assert.deepEqual(cfg, { pythonFiles: ["check_*.py"], testpaths: ["tests", "integration"], pythonpath: ["src"] });
});

it("skips a tox.ini without [pytest] in favour of setup.cfg", () => {
const files: Record<string, string> = {
"tox.ini": "[tox]\nenvlist = py312\n\n[testenv]\ncommands = pytest\n",
"setup.cfg": "[tool:pytest]\ntestpaths = from_setup_cfg\n",
};
assert.deepEqual(readPytestSettings((path) => files[path]).testpaths, ["from_setup_cfg"]);
});
});

// Only decides whether Python is available at all. Assertions use the interpreter the analysis recorded:
// a second probe can pick another launcher on Windows (#304).
const pythonAvailable = pythonInterpreter(process.cwd()) !== undefined;
Expand Down
Loading