@@ -25,7 +25,13 @@ describe('getOptions', () => {
2525 const cwd = join ( 'path' , 'to' , 'work' , 'dir' )
2626
2727 it ( 'should give the correct options given a basic environment' , ( ) => {
28- const options = getOptions ( undefined , '' , cwd , Command . CHECKOUT , Flag . FORCE )
28+ const options = getOptions ( {
29+ PYTHONPATH : undefined ,
30+ args : [ Command . CHECKOUT , Flag . FORCE ] ,
31+ cliPath : '' ,
32+ cwd,
33+ pythonBinPath : undefined
34+ } )
2935 expect ( options ) . toStrictEqual ( {
3036 args : [ 'checkout' , '-f' ] ,
3137 cwd,
@@ -36,7 +42,13 @@ describe('getOptions', () => {
3642
3743 it ( 'should append -m dvc to the args and use the python as the executable if only an isolated python env is in use' , ( ) => {
3844 const pythonBinPath = join ( 'path' , 'to' , 'python' , '.venv' , 'python' )
39- const options = getOptions ( pythonBinPath , '' , cwd , Command . PULL )
45+ const options = getOptions ( {
46+ PYTHONPATH : undefined ,
47+ args : [ Command . PULL ] ,
48+ cliPath : '' ,
49+ cwd,
50+ pythonBinPath
51+ } )
4052 expect ( options ) . toStrictEqual ( {
4153 args : [ '-m' , 'dvc' , 'pull' ] ,
4254 cwd,
@@ -53,7 +65,13 @@ describe('getOptions', () => {
5365 it ( 'should append to the PATH but only use the path to the cli if both an isolated python env and path to dvc are in use' , ( ) => {
5466 const pythonBinPath = join ( 'path' , 'to' , 'python' , '.venv' , 'python' )
5567 const cliPath = join ( 'custom' , 'path' , 'to' , 'dvc' )
56- const options = getOptions ( pythonBinPath , cliPath , cwd , Command . PULL )
68+ const options = getOptions ( {
69+ PYTHONPATH : undefined ,
70+ args : [ Command . PULL ] ,
71+ cliPath,
72+ cwd,
73+ pythonBinPath
74+ } )
5775 expect ( options ) . toStrictEqual ( {
5876 args : [ 'pull' ] ,
5977 cwd,
@@ -66,4 +84,30 @@ describe('getOptions', () => {
6684 executable : cliPath
6785 } )
6886 } )
87+
88+ it ( 'should add PYTHONPATH to the environment variables if it is provided' , ( ) => {
89+ const PYTHONPATH = join ( 'path' , 'to' , 'project' )
90+ const venvPath = join ( PYTHONPATH , '.venv' )
91+ const pythonBinPath = join ( venvPath , 'python' )
92+ const cliPath = ''
93+ const options = getOptions ( {
94+ PYTHONPATH ,
95+ args : [ Command . PULL ] ,
96+ cliPath,
97+ cwd,
98+ pythonBinPath
99+ } )
100+ expect ( options ) . toStrictEqual ( {
101+ args : [ '-m' , 'dvc' , 'pull' ] ,
102+ cwd,
103+ env : {
104+ DVCLIVE_OPEN : 'false' ,
105+ DVC_NO_ANALYTICS : 'true' ,
106+ GIT_TERMINAL_PROMPT : '0' ,
107+ PATH : joinEnvPath ( venvPath , mockedPATH ) ,
108+ PYTHONPATH
109+ } ,
110+ executable : pythonBinPath
111+ } )
112+ } )
69113} )
0 commit comments