@@ -33,18 +33,32 @@ def test_unset():
3333 assert success is None
3434
3535
36- def test_console_script ():
37- sh .touch (dotenv_path )
38- sh .dotenv ('-f' , dotenv_path , 'set' , 'HELLO' , 'WORLD' )
39- output = sh .dotenv ('-f' , dotenv_path , 'get' , 'HELLO' , )
40- assert output == 'HELLO="WORLD"\n '
41- sh .rm (dotenv_path )
36+ def test_console_script (cli ):
37+ with cli .isolated_filesystem ():
38+ sh .touch (dotenv_path )
39+ sh .dotenv ('-f' , dotenv_path , 'set' , 'HELLO' , 'WORLD' )
40+ output = sh .dotenv ('-f' , dotenv_path , 'get' , 'HELLO' , )
41+ assert output == 'HELLO="WORLD"\n '
42+ sh .rm (dotenv_path )
4243
44+ # should fail for not existing file
45+ result = cli .invoke (dotenv .set , ['my_key' , 'my_value' ])
46+ assert result .exit_code != 0
4347
44- def test_default_path ():
45- sh .touch (dotenv_path )
46- sh .cd (here )
47- sh .dotenv ('set' , 'HELLO' , 'WORLD' )
48- output = sh .dotenv ('get' , 'HELLO' )
49- assert output == 'HELLO="WORLD"\n '
50- sh .rm (dotenv_path )
48+ # should fail for not existing file
49+ result = cli .invoke (dotenv .get , ['my_key' ])
50+ assert result .exit_code != 0
51+
52+ # should fail for not existing file
53+ result = cli .invoke (dotenv .list , [])
54+ assert result .exit_code != 0
55+
56+
57+ def test_default_path (cli ):
58+ with cli .isolated_filesystem ():
59+ sh .touch (dotenv_path )
60+ sh .cd (here )
61+ sh .dotenv ('set' , 'HELLO' , 'WORLD' )
62+ output = sh .dotenv ('get' , 'HELLO' )
63+ assert output == 'HELLO="WORLD"\n '
64+ sh .rm (dotenv_path )
0 commit comments