Skip to content

Commit a40d3ab

Browse files
committed
Resolve merge conflicts
1 parent 09d7cee commit a40d3ab

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import sys
66
import textwrap
77
from unittest import mock
8+
from dotenv import dotenv_values
9+
10+
811

912
import pytest
1013

@@ -565,3 +568,29 @@ def test_dotenv_values_file_stream(dotenv_path):
565568
result = dotenv.dotenv_values(stream=f)
566569

567570
assert result == {"a": "b"}
571+
572+
def _read_dotenv_stream(path):
573+
"""
574+
Safely read a .env file line by line.
575+
Works on:
576+
- Regular files
577+
- FIFOs (macOS/Linux)
578+
- fd-backed files (1Password)
579+
- Windows special files
580+
"""
581+
try:
582+
with open(path, "r", encoding="utf-8", errors="replace") as f:
583+
return "".join(line for line in f)
584+
except (OSError, IOError):
585+
return ""
586+
587+
@pytest.mark.skipif(os.name != "nt", reason="Windows-specific test")
588+
def test_windows_fd_env_file(tmp_path):
589+
"""
590+
Simulate a Windows fd-backed .env file (like 1Password mount).
591+
"""
592+
env_path = tmp_path / "win_env.env"
593+
env_path.write_text("FOO=bar\n") # simulate fd-backed behavior
594+
595+
values = dotenv_values(env_path)
596+
assert values["FOO"] == "bar"

0 commit comments

Comments
 (0)