1- // tslint:disable:interface-name no-any max-func-body-length estrict-plus-operands
1+ // tslint:disable:interface-name no-any max-func-body-length estrict-plus-operands no-empty
22
33import * as assert from 'assert' ;
44import * as fs from 'fs-extra' ;
@@ -10,12 +10,12 @@ import { getTextEditsFromPatch } from '../../client/common/editor';
1010import { extractMethod } from '../../client/providers/simpleRefactorProvider' ;
1111import { RefactorProxy } from '../../client/refactor/proxy' ;
1212import { UnitTestIocContainer } from '../unittests/serviceRegistry' ;
13- import { closeActiveWindows , initialize , initializeTest , wait } from './../initialize' ;
13+ import { closeActiveWindows , initialize , initializeTest } from './../initialize' ;
1414import { MockOutputChannel } from './../mockClasses' ;
1515
1616const EXTENSION_DIR = path . join ( __dirname , '..' , '..' , '..' ) ;
1717const refactorSourceFile = path . join ( __dirname , '..' , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' , 'refactor.py' ) ;
18- const refactorTargetFile = path . join ( __dirname , '..' , '..' , '..' , 'out' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' , 'refactor.py ') ;
18+ const refactorTargetFileDir = path . join ( __dirname , '..' , '..' , '..' , 'out' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' ) ;
1919
2020interface RenameResponse {
2121 results : [ { diff : string } ] ;
@@ -25,31 +25,27 @@ suite('Method Extraction', () => {
2525 // Hack hac hack
2626 const oldExecuteCommand = vscode . commands . executeCommand ;
2727 const options : vscode . TextEditorOptions = { cursorStyle : vscode . TextEditorCursorStyle . Line , insertSpaces : true , lineNumbers : vscode . TextEditorLineNumbersStyle . Off , tabSize : 4 } ;
28-
28+ let refactorTargetFile = '' ;
2929 let ioc : UnitTestIocContainer ;
30- suiteSetup ( async ( ) => {
31- fs . copySync ( refactorSourceFile , refactorTargetFile , { overwrite : true } ) ;
32- await initialize ( ) ;
33- initializeDI ( ) ;
34- } ) ;
30+ suiteSetup ( initialize ) ;
3531 suiteTeardown ( ( ) => {
3632 vscode . commands . executeCommand = oldExecuteCommand ;
3733 return closeActiveWindows ( ) ;
3834 } ) ;
3935 setup ( async ( ) => {
40- if ( fs . existsSync ( refactorTargetFile ) ) {
41- await wait ( 500 ) ;
42- fs . unlinkSync ( refactorTargetFile ) ;
43- }
36+ initializeDI ( ) ;
37+ refactorTargetFile = path . join ( refactorTargetFileDir , `refactor${ new Date ( ) . getTime ( ) } .py` ) ;
4438 fs . copySync ( refactorSourceFile , refactorTargetFile , { overwrite : true } ) ;
4539 await initializeTest ( ) ;
4640 ( < any > vscode ) . commands . executeCommand = ( cmd ) => Promise . resolve ( ) ;
4741 } ) ;
48- teardown ( ( ) => {
42+ teardown ( async ( ) => {
4943 vscode . commands . executeCommand = oldExecuteCommand ;
50- return closeActiveWindows ( ) ;
44+ try {
45+ await fs . unlink ( refactorTargetFile ) ;
46+ } catch { }
47+ await closeActiveWindows ( ) ;
5148 } ) ;
52-
5349 function initializeDI ( ) {
5450 ioc = new UnitTestIocContainer ( ) ;
5551 ioc . registerCommonTypes ( ) ;
0 commit comments