@@ -22,8 +22,9 @@ import * as configSettings from '../client/common/configSettings';
2222
2323let pythonSettings = configSettings . PythonSettings . getInstance ( ) ;
2424
25- const UNITTEST_TEST_FILES_PATH = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'unitests' ) ;
26- const UNITTEST_TEST_ID_FILE_PATH = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'unitests' , '.noseids' ) ;
25+ const UNITTEST_TEST_FILES_PATH = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'testFiles' , 'standard' ) ;
26+ const UNITTEST_SINGLE_TEST_FILE_PATH = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'testFiles' , 'single' ) ;
27+ const UNITTEST_TEST_ID_FILE_PATH = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'testFiles' , 'standard' , '.noseids' ) ;
2728class MockOutputChannel implements vscode . OutputChannel {
2829 constructor ( name : string ) {
2930 this . name = name ;
@@ -45,7 +46,7 @@ class MockOutputChannel implements vscode.OutputChannel {
4546
4647suite ( 'Unit Tests (nosetest)' , ( ) => {
4748 suiteSetup ( done => {
48- if ( fs . existsSync ( UNITTEST_TEST_ID_FILE_PATH ) ) {
49+ if ( fs . existsSync ( UNITTEST_TEST_ID_FILE_PATH ) ) {
4950 fs . unlinkSync ( UNITTEST_TEST_ID_FILE_PATH ) ;
5051 }
5152 initialize ( ) . then ( ( ) => {
@@ -54,7 +55,7 @@ suite('Unit Tests (nosetest)', () => {
5455 } ) ;
5556 } ) ;
5657 suiteTeardown ( done => {
57- if ( fs . existsSync ( UNITTEST_TEST_ID_FILE_PATH ) ) {
58+ if ( fs . existsSync ( UNITTEST_TEST_ID_FILE_PATH ) ) {
5859 fs . unlinkSync ( UNITTEST_TEST_ID_FILE_PATH ) ;
5960 }
6061 done ( ) ;
@@ -76,38 +77,50 @@ suite('Unit Tests (nosetest)', () => {
7677 let testResultDisplay : TestResultDisplay ;
7778 let outChannel : vscode . OutputChannel ;
7879
80+ test ( 'Discover Tests (single test file)' , done => {
81+ pythonSettings . unitTest . nosetestArgs = [
82+ ] ;
83+ testManager = new nose . TestManager ( UNITTEST_SINGLE_TEST_FILE_PATH , outChannel ) ;
84+ testManager . discoverTests ( true , true ) . then ( tests => {
85+ assert . equal ( tests . testFiles . length , 1 , 'Incorrect number of test files' ) ;
86+ assert . equal ( tests . testFunctions . length , 3 , 'Incorrect number of test functions' ) ;
87+ assert . equal ( tests . testSuits . length , 1 , 'Incorrect number of test suites' ) ;
88+ assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_one.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
89+ } ) . then ( done ) . catch ( done ) ;
90+ } ) ;
91+
7992 test ( 'Discover Tests (pattern = test_)' , done => {
8093 pythonSettings . unitTest . nosetestArgs = [
8194
8295 ] ;
8396 createTestManager ( ) ;
8497 testManager . discoverTests ( true , true ) . then ( tests => {
85- assert . equal ( tests . testFiles . length , 4 , 'Incorrect number of test files' ) ;
86- assert . equal ( tests . testFunctions . length , 17 , 'Incorrect number of test functions' ) ;
87- assert . equal ( tests . testSuits . length , 4 , 'Incorrect number of test suites' ) ;
98+ assert . equal ( tests . testFiles . length , 5 , 'Incorrect number of test files' ) ;
99+ assert . equal ( tests . testFunctions . length , 19 , 'Incorrect number of test functions' ) ;
100+ assert . equal ( tests . testSuits . length , 5 , 'Incorrect number of test suites' ) ;
88101 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_unittest_one.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
89102 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_unittest_two.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
90103 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_pytest.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
91104 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_another_pytest.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
92- done ( ) ;
93- } ) . catch ( done ) ;
105+ assert . equal ( tests . testFiles . some ( t => t . name === 'tests/unittest_three_test.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
106+ } ) . then ( done ) . catch ( done ) ;
94107 } ) ;
95108
96- test ( 'Discover Tests (pattern = test_ )' , done => {
109+ test ( 'Discover Tests (pattern = _test_ )' , done => {
97110 pythonSettings . unitTest . nosetestArgs = [
98111 '-m=*test*'
99112 ] ;
100113 createTestManager ( ) ;
101114 testManager . discoverTests ( true , true ) . then ( tests => {
102- assert . equal ( tests . testFiles . length , 4 , 'Incorrect number of test files' ) ;
103- assert . equal ( tests . testFunctions . length , 13 , 'Incorrect number of test functions' ) ;
104- assert . equal ( tests . testSuits . length , 3 , 'Incorrect number of test suites' ) ;
115+ assert . equal ( tests . testFiles . length , 5 , 'Incorrect number of test files' ) ;
116+ assert . equal ( tests . testFunctions . length , 15 , 'Incorrect number of test functions' ) ;
117+ assert . equal ( tests . testSuits . length , 4 , 'Incorrect number of test suites' ) ;
105118 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_unittest_one.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
106119 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_unittest_two.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
107120 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_pytest.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
108121 assert . equal ( tests . testFiles . some ( t => t . name === 'tests/test_another_pytest.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
109- done ( ) ;
110- } ) . catch ( done ) ;
122+ assert . equal ( tests . testFiles . some ( t => t . name === 'tests/unittest_three_test.py' && t . nameToRun === t . name ) , true , 'Test File not found' ) ;
123+ } ) . then ( done ) . catch ( done ) ;
111124 } ) ;
112125
113126 test ( 'Run Tests' , done => {
@@ -119,8 +132,7 @@ suite('Unit Tests (nosetest)', () => {
119132 assert . equal ( results . summary . failures , 5 , 'Failures' ) ;
120133 assert . equal ( results . summary . passed , 7 , 'Passed' ) ;
121134 assert . equal ( results . summary . skipped , 2 , 'skipped' ) ;
122- done ( ) ;
123- } ) . catch ( done ) ;
135+ } ) . then ( done ) . catch ( done ) ;
124136 } ) ;
125137
126138 test ( 'Run Failed Tests' , done => {
@@ -138,9 +150,8 @@ suite('Unit Tests (nosetest)', () => {
138150 assert . equal ( results . summary . failures , 5 , 'Failures' ) ;
139151 assert . equal ( results . summary . passed , 0 , 'Passed' ) ;
140152 assert . equal ( results . summary . skipped , 0 , 'skipped' ) ;
141- done ( ) ;
142153 } ) ;
143- } ) . catch ( done ) ;
154+ } ) . then ( done ) . catch ( done ) ;
144155 } ) ;
145156
146157 test ( 'Run Specific Test File' , done => {
@@ -154,9 +165,8 @@ suite('Unit Tests (nosetest)', () => {
154165 assert . equal ( tests . summary . failures , 0 , 'Failures' ) ;
155166 assert . equal ( tests . summary . passed , 0 , 'Passed' ) ;
156167 assert . equal ( tests . summary . skipped , 0 , 'skipped' ) ;
157- done ( ) ;
158168 } ) ;
159- } ) . catch ( done ) ;
169+ } ) . then ( done ) . catch ( done ) ;
160170 } ) ;
161171
162172 test ( 'Run Specific Test Suite' , done => {
@@ -170,9 +180,8 @@ suite('Unit Tests (nosetest)', () => {
170180 assert . equal ( tests . summary . failures , 0 , 'Failures' ) ;
171181 assert . equal ( tests . summary . passed , 0 , 'Passed' ) ;
172182 assert . equal ( tests . summary . skipped , 0 , 'skipped' ) ;
173- done ( ) ;
174183 } ) ;
175- } ) . catch ( done ) ;
184+ } ) . then ( done ) . catch ( done ) ;
176185 } ) ;
177186
178187 test ( 'Run Specific Test Function' , done => {
@@ -186,8 +195,7 @@ suite('Unit Tests (nosetest)', () => {
186195 assert . equal ( tests . summary . failures , 0 , 'Failures' ) ;
187196 assert . equal ( tests . summary . passed , 0 , 'Passed' ) ;
188197 assert . equal ( tests . summary . skipped , 0 , 'skipped' ) ;
189- done ( ) ;
190198 } ) ;
191- } ) . catch ( done ) ;
199+ } ) . then ( done ) . catch ( done ) ;
192200 } ) ;
193201} ) ;
0 commit comments