@@ -5,7 +5,7 @@ import { assert, expect } from 'chai';
55import * as path from 'path' ;
66import * as sinon from 'sinon' ;
77import { ExecutionResult , ShellOptions } from '../../../../client/common/process/types' ;
8- import { getUserHomeDir } from '../../../../client/common/utils/platform' ;
8+ import * as platformApis from '../../../../client/common/utils/platform' ;
99import * as externalDependencies from '../../../../client/pythonEnvironments/common/externalDependencies' ;
1010import { isPoetryEnvironment , Poetry } from '../../../../client/pythonEnvironments/common/environmentManagers/poetry' ;
1111import { TEST_LAYOUT_ROOT } from '../commonTestConstants' ;
@@ -20,6 +20,12 @@ suite('isPoetryEnvironment Tests', () => {
2020 let getPythonSetting : sinon . SinonStub ;
2121
2222 suite ( 'Global poetry environment' , async ( ) => {
23+ setup ( ( ) => {
24+ sinon . stub ( platformApis , 'getOSType' ) . callsFake ( ( ) => platformApis . OSType . Windows ) ;
25+ } ) ;
26+ teardown ( ( ) => {
27+ sinon . restore ( ) ;
28+ } ) ;
2329 test ( 'Return true if environment folder name matches global env pattern and environment is of virtual env type' , async ( ) => {
2430 const result = await isPoetryEnvironment (
2531 path . join ( testPoetryDir , 'poetry-tutorial-project-6hnqYwvD-py3.8' , 'Scripts' , 'python.exe' ) ,
@@ -60,16 +66,19 @@ suite('isPoetryEnvironment Tests', () => {
6066 } ) ;
6167
6268 test ( 'Return true if environment folder name matches criteria for local envs' , async ( ) => {
69+ sinon . stub ( platformApis , 'getOSType' ) . callsFake ( ( ) => platformApis . OSType . Windows ) ;
6370 const result = await isPoetryEnvironment ( path . join ( project1 , '.venv' , 'Scripts' , 'python.exe' ) ) ;
6471 expect ( result ) . to . equal ( true ) ;
6572 } ) ;
6673
6774 test ( `Return false if environment folder name is not named '.venv' for local envs` , async ( ) => {
75+ sinon . stub ( platformApis , 'getOSType' ) . callsFake ( ( ) => platformApis . OSType . Windows ) ;
6876 const result = await isPoetryEnvironment ( path . join ( project1 , '.venv2' , 'Scripts' , 'python.exe' ) ) ;
6977 expect ( result ) . to . equal ( false ) ;
7078 } ) ;
7179
7280 test ( `Return false if running poetry for project dir as cwd fails (pyproject.toml file is invalid)` , async ( ) => {
81+ sinon . stub ( platformApis , 'getOSType' ) . callsFake ( ( ) => platformApis . OSType . Linux ) ;
7382 const result = await isPoetryEnvironment ( path . join ( project4 , '.venv' , 'bin' , 'python' ) ) ;
7483 expect ( result ) . to . equal ( false ) ;
7584 } ) ;
@@ -148,7 +157,7 @@ suite('Poetry binary is located correctly', async () => {
148157 } ) ;
149158
150159 test ( 'When poetry is not available on PATH, try using the default poetry location if valid' , async ( ) => {
151- const home = getUserHomeDir ( ) ;
160+ const home = platformApis . getUserHomeDir ( ) ;
152161 if ( ! home ) {
153162 assert ( true ) ;
154163 return ;
0 commit comments