Skip to content

Commit bb61d26

Browse files
efremovdDonJayamanne
authored andcommitted
Fixes nose run test on test case (DonJayamanne#1225)
* Fixes issue when tests won't run on testcase with nose * Adds addtional checking to new test * Fixes run specific testsuite test
1 parent f5985d3 commit bb61d26

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/client/unittests/nosetest/collector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ function parseNoseTestModuleCollectionResult(rootDirectory: string, lines: strin
117117

118118
if (line.startsWith('nose.selector: DEBUG: wantClass <class \'')) {
119119
let name = extractBetweenDelimiters(line, 'nose.selector: DEBUG: wantClass <class \'', '\'>? True');
120+
const clsName = path.extname(name).substring(1);
120121
const testSuite: TestSuite = {
121-
name: path.extname(name).substring(1), nameToRun: fileName + `:${name}`,
122+
name: clsName, nameToRun: fileName + `:${clsName}`,
122123
functions: [], suites: [], xmlName: name, time: 0, isUnitTest: false,
123124
isInstance: false, functionsFailed: 0, functionsPassed: 0
124125
};

src/test/unittests/extension.unittests.nosetest.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ suite('Unit Tests (nosetest)', () => {
6464
assert.equal(tests.testFiles.some(t => t.name === path.join('tests', 'test_one.py') && t.nameToRun === t.name), true, 'Test File not found');
6565
});
6666

67+
test('Check that nameToRun in testSuits has class name after : (single test file)', async () => {
68+
pythonSettings.unitTest.nosetestArgs = [];
69+
testManager = new nose.TestManager(UNITTEST_SINGLE_TEST_FILE_PATH, outChannel);
70+
const tests = await testManager.discoverTests(true, true);
71+
assert.equal(tests.testFiles.length, 2, 'Incorrect number of test files');
72+
assert.equal(tests.testFunctions.length, 6, 'Incorrect number of test functions');
73+
assert.equal(tests.testSuits.length, 2, 'Incorrect number of test suites');
74+
assert.equal(tests.testSuits.every(t => t.testSuite.name === t.testSuite.nameToRun.split(":")[1]), true, 'Suite name does not match class name');
75+
});
76+
6777
test('Discover Tests (pattern = test_)', async () => {
6878
pythonSettings.unitTest.nosetestArgs = [];
6979
createTestManager();
@@ -140,10 +150,10 @@ suite('Unit Tests (nosetest)', () => {
140150
const tests = await testManager.discoverTests(true, true);
141151
const testSuite: TestsToRun = { testFile: [], testFolder: [], testFunction: [], testSuite: [tests.testSuits[0].testSuite] };
142152
const results = await testManager.runTest(testSuite);
143-
assert.equal(results.summary.errors, 1, 'Errors');
144-
assert.equal(results.summary.failures, 0, 'Failures');
145-
assert.equal(results.summary.passed, 0, 'Passed');
146-
assert.equal(results.summary.skipped, 0, 'skipped');
153+
assert.equal(results.summary.errors, 0, 'Errors');
154+
assert.equal(results.summary.failures, 1, 'Failures');
155+
assert.equal(results.summary.passed, 1, 'Passed');
156+
assert.equal(results.summary.skipped, 1, 'skipped');
147157
});
148158

149159
test('Run Specific Test Function', async () => {

0 commit comments

Comments
 (0)