@@ -22,6 +22,8 @@ const fileToFormatWithoutConfig = path.join(__dirname, '..', '..', 'src', 'test'
2222const originalFileToFormatWithoutConfig = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'noconfig' , 'original.py' ) ;
2323const fileToFormatWithConfig = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' , 'before.py' ) ;
2424const originalFileToFormatWithConfig = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' , 'original.py' ) ;
25+ const fileToFormatWithConfig1 = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' , 'before.1.py' ) ;
26+ const originalFileToFormatWithConfig1 = path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' , 'original.1.py' ) ;
2527const extensionDir = path . join ( __dirname , '..' , '..' ) ;
2628
2729suite ( 'Formatting' , ( ) => {
@@ -33,6 +35,7 @@ suite('Formatting', () => {
3335
3436 suiteTeardown ( ( ) => {
3537 fs . writeFileSync ( fileToFormatWithConfig , fs . readFileSync ( originalFileToFormatWithConfig ) ) ;
38+ fs . writeFileSync ( fileToFormatWithConfig1 , fs . readFileSync ( originalFileToFormatWithConfig1 ) ) ;
3639 fs . writeFileSync ( fileToFormatWithoutConfig , fs . readFileSync ( originalFileToFormatWithoutConfig ) ) ;
3740 if ( vscode . window . activeTextEditor ) {
3841 return vscode . commands . executeCommand ( 'workbench.action.closeActiveEditor' ) ;
@@ -42,10 +45,12 @@ suite('Formatting', () => {
4245 pythonSettings . sortImports . args = [ ] ;
4346 fs . writeFileSync ( fileToFormatWithConfig , fs . readFileSync ( originalFileToFormatWithConfig ) ) ;
4447 fs . writeFileSync ( fileToFormatWithoutConfig , fs . readFileSync ( originalFileToFormatWithoutConfig ) ) ;
48+ fs . writeFileSync ( fileToFormatWithConfig1 , fs . readFileSync ( originalFileToFormatWithConfig1 ) ) ;
4549 } ) ;
4650 teardown ( ( ) => {
4751 fs . writeFileSync ( fileToFormatWithConfig , fs . readFileSync ( originalFileToFormatWithConfig ) ) ;
4852 fs . writeFileSync ( fileToFormatWithoutConfig , fs . readFileSync ( originalFileToFormatWithoutConfig ) ) ;
53+ fs . writeFileSync ( fileToFormatWithConfig1 , fs . readFileSync ( originalFileToFormatWithConfig1 ) ) ;
4954 if ( vscode . window . activeTextEditor ) {
5055 return vscode . commands . executeCommand ( 'workbench.action.closeActiveEditor' ) ;
5156 }
@@ -117,34 +122,29 @@ suite('Formatting', () => {
117122 } ) . then ( done , done ) ;
118123 } ) ;
119124
120- // Lol this doesn't work
121- // VS Code repeatedly fails to open the document with the following error
122- // "Error: Failed to show text document file:///.../before.py, should show in editor #undefined"
123- if ( ! IS_TRAVIS ) {
124- test ( 'With Changes and Config in Args' , done => {
125- let textEditor : vscode . TextEditor ;
126- let textDocument : vscode . TextDocument ;
127- pythonSettings . sortImports . args = [ '-sp' , path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' ) ] ;
128- return vscode . workspace . openTextDocument ( fileToFormatWithConfig ) . then ( document => {
129- textDocument = document ;
130- return vscode . window . showTextDocument ( textDocument ) ;
131- } ) . then ( editor => {
132- textEditor = editor ;
133- return editor . edit ( editor => {
134- editor . insert ( new vscode . Position ( 0 , 0 ) , 'from third_party import lib0' + EOL ) ;
135- } ) ;
136- } ) . then ( ( ) => {
137- const sorter = new PythonImportSortProvider ( ) ;
138- return sorter . sortImports ( extensionDir , textDocument ) ;
139- } ) . then ( edits => {
140- const newValue = `from third_party import lib1${ EOL } from third_party import lib2${ EOL } from third_party import lib3${ EOL } from third_party import lib4${ EOL } from third_party import lib5${ EOL } from third_party import lib6${ EOL } from third_party import lib7${ EOL } from third_party import lib8${ EOL } from third_party import lib9${ EOL } ` ;
141- assert . equal ( edits . length , 1 , 'Incorrect number of edits' ) ;
142- assert . equal ( edits [ 0 ] . newText , newValue , 'New Value is not the same' ) ;
143- assert . equal ( `${ edits [ 0 ] . range . start . line } ,${ edits [ 0 ] . range . start . character } ` , '1,0' , 'Start position is not the same' ) ;
144- assert . equal ( `${ edits [ 0 ] . range . end . line } ,${ edits [ 0 ] . range . end . character } ` , '2,0' , 'End position is not the same' ) ;
145- } ) . then ( done , done ) ;
146- } ) ;
147- }
125+ test ( 'With Changes and Config in Args' , done => {
126+ let textEditor : vscode . TextEditor ;
127+ let textDocument : vscode . TextDocument ;
128+ pythonSettings . sortImports . args = [ '-sp' , path . join ( __dirname , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'sorting' , 'withconfig' ) ] ;
129+ return vscode . workspace . openTextDocument ( fileToFormatWithConfig ) . then ( document => {
130+ textDocument = document ;
131+ return vscode . window . showTextDocument ( textDocument ) ;
132+ } ) . then ( editor => {
133+ textEditor = editor ;
134+ return editor . edit ( editor => {
135+ editor . insert ( new vscode . Position ( 0 , 0 ) , 'from third_party import lib0' + EOL ) ;
136+ } ) ;
137+ } ) . then ( ( ) => {
138+ const sorter = new PythonImportSortProvider ( ) ;
139+ return sorter . sortImports ( extensionDir , textDocument ) ;
140+ } ) . then ( edits => {
141+ const newValue = `from third_party import lib1${ EOL } from third_party import lib2${ EOL } from third_party import lib3${ EOL } from third_party import lib4${ EOL } from third_party import lib5${ EOL } from third_party import lib6${ EOL } from third_party import lib7${ EOL } from third_party import lib8${ EOL } from third_party import lib9${ EOL } ` ;
142+ assert . equal ( edits . length , 1 , 'Incorrect number of edits' ) ;
143+ assert . equal ( edits [ 0 ] . newText , newValue , 'New Value is not the same' ) ;
144+ assert . equal ( `${ edits [ 0 ] . range . start . line } ,${ edits [ 0 ] . range . start . character } ` , '1,0' , 'Start position is not the same' ) ;
145+ assert . equal ( `${ edits [ 0 ] . range . end . line } ,${ edits [ 0 ] . range . end . character } ` , '2,0' , 'End position is not the same' ) ;
146+ } ) . then ( done , done ) ;
147+ } ) ;
148148
149149 test ( 'With Changes and Config in Args (via Command)' , done => {
150150 let textEditor : vscode . TextEditor ;
0 commit comments