@@ -28,9 +28,9 @@ def test_set_key_no_file(tmp_path):
28
28
("" , "a" , "" , (True , "a" , "" ), "a=''\n " ),
29
29
("" , "a" , "b" , (True , "a" , "b" ), "a='b'\n " ),
30
30
("" , "a" , "'b'" , (True , "a" , "'b'" ), "a='\\ 'b\\ ''\n " ),
31
- ("" , "a" , " \" b \" " , (True , "a" , '"b"' ), "a='\" b\" '\n " ),
31
+ ("" , "a" , '"b"' , (True , "a" , '"b"' ), "a='\" b\" '\n " ),
32
32
("" , "a" , "b'c" , (True , "a" , "b'c" ), "a='b\\ 'c'\n " ),
33
- ("" , "a" , "b \" c" , (True , "a" , "b \" c" ), "a='b\" c'\n " ),
33
+ ("" , "a" , 'b"c' , (True , "a" , 'b"c' ), "a='b\" c'\n " ),
34
34
("a=b" , "a" , "c" , (True , "a" , "c" ), "a='c'\n " ),
35
35
("a=b\n " , "a" , "c" , (True , "a" , "c" ), "a='c'\n " ),
36
36
("a=b\n \n " , "a" , "c" , (True , "a" , "c" ), "a='c'\n \n " ),
@@ -75,20 +75,20 @@ def test_get_key_no_file(tmp_path):
75
75
nx_path = tmp_path / "nx"
76
76
logger = logging .getLogger ("dotenv.main" )
77
77
78
- with mock .patch .object (logger , "info" ) as mock_info , \
79
- mock .patch .object (logger , "warning" ) as mock_warning :
78
+ with (
79
+ mock .patch .object (logger , "info" ) as mock_info ,
80
+ mock .patch .object (logger , "warning" ) as mock_warning ,
81
+ ):
80
82
result = dotenv .get_key (nx_path , "foo" )
81
83
82
84
assert result is None
83
85
mock_info .assert_has_calls (
84
86
calls = [
85
- mock .call ("Python -dotenv could not find configuration file %s." , nx_path )
87
+ mock .call ("python -dotenv could not find configuration file %s." , nx_path )
86
88
],
87
89
)
88
90
mock_warning .assert_has_calls (
89
- calls = [
90
- mock .call ("Key %s not found in %s." , "foo" , nx_path )
91
- ],
91
+ calls = [mock .call ("Key %s not found in %s." , "foo" , nx_path )],
92
92
)
93
93
94
94
@@ -249,10 +249,12 @@ def test_load_dotenv_no_file_verbose():
249
249
logger = logging .getLogger ("dotenv.main" )
250
250
251
251
with mock .patch .object (logger , "info" ) as mock_info :
252
- result = dotenv .load_dotenv (' .does_not_exist' , verbose = True )
252
+ result = dotenv .load_dotenv (" .does_not_exist" , verbose = True )
253
253
254
254
assert result is False
255
- mock_info .assert_called_once_with ("Python-dotenv could not find configuration file %s." , ".does_not_exist" )
255
+ mock_info .assert_called_once_with (
256
+ "python-dotenv could not find configuration file %s." , ".does_not_exist"
257
+ )
256
258
257
259
258
260
@mock .patch .dict (os .environ , {"a" : "c" }, clear = True )
@@ -317,21 +319,23 @@ def test_load_dotenv_file_stream(dotenv_path):
317
319
318
320
319
321
def test_load_dotenv_in_current_dir (tmp_path ):
320
- dotenv_path = tmp_path / '.env'
321
- dotenv_path .write_bytes (b'a=b' )
322
- code_path = tmp_path / 'code.py'
323
- code_path .write_text (textwrap .dedent ("""
322
+ dotenv_path = tmp_path / ".env"
323
+ dotenv_path .write_bytes (b"a=b" )
324
+ code_path = tmp_path / "code.py"
325
+ code_path .write_text (
326
+ textwrap .dedent ("""
324
327
import dotenv
325
328
import os
326
329
327
330
dotenv.load_dotenv(verbose=True)
328
331
print(os.environ['a'])
329
- """ ))
332
+ """ )
333
+ )
330
334
os .chdir (tmp_path )
331
335
332
336
result = sh .Command (sys .executable )(code_path )
333
337
334
- assert result == ' b\n '
338
+ assert result == " b\n "
335
339
336
340
337
341
def test_dotenv_values_file (dotenv_path ):
@@ -352,30 +356,23 @@ def test_dotenv_values_file(dotenv_path):
352
356
({"b" : "c" }, "a=${b}" , True , {"a" : "c" }),
353
357
({"b" : "c" }, "a=${b:-d}" , False , {"a" : "${b:-d}" }),
354
358
({"b" : "c" }, "a=${b:-d}" , True , {"a" : "c" }),
355
-
356
359
# Defined in file
357
360
({}, "b=c\n a=${b}" , True , {"a" : "c" , "b" : "c" }),
358
-
359
361
# Undefined
360
362
({}, "a=${b}" , True , {"a" : "" }),
361
363
({}, "a=${b:-d}" , True , {"a" : "d" }),
362
-
363
364
# With quotes
364
365
({"b" : "c" }, 'a="${b}"' , True , {"a" : "c" }),
365
366
({"b" : "c" }, "a='${b}'" , True , {"a" : "c" }),
366
-
367
367
# With surrounding text
368
368
({"b" : "c" }, "a=x${b}y" , True , {"a" : "xcy" }),
369
-
370
369
# Self-referential
371
370
({"a" : "b" }, "a=${a}" , True , {"a" : "b" }),
372
371
({}, "a=${a}" , True , {"a" : "" }),
373
372
({"a" : "b" }, "a=${a:-c}" , True , {"a" : "b" }),
374
373
({}, "a=${a:-c}" , True , {"a" : "c" }),
375
-
376
374
# Reused
377
375
({"b" : "c" }, "a=${b}${b}" , True , {"a" : "cc" }),
378
-
379
376
# Re-defined and used in file
380
377
({"b" : "c" }, "b=d\n a=${b}" , True , {"a" : "d" , "b" : "d" }),
381
378
({}, "a=b\n a=c\n d=${a}" , True , {"a" : "c" , "d" : "c" }),
0 commit comments