Skip to content

Commit 280cb17

Browse files
committed
Add Windows testing to CI
1 parent f54d29f commit 280cb17

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ jobs:
1414
- ubuntu-latest
1515
python-version:
1616
["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", pypy3.9, pypy3.10]
17+
include:
18+
# Test lowest and highest Python versions on Windows
19+
- os: windows-latest
20+
python-version: "3.9"
21+
- os: windows-latest
22+
python-version: "3.14"
1723

1824
steps:
1925
- uses: actions/checkout@v6

tests/test_cli.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import os
2+
import sys
23
from pathlib import Path
34
from typing import Optional
45

56
import pytest
6-
import sh
77

88
import dotenv
99
from dotenv.cli import cli as dotenv_cli
1010
from dotenv.version import __version__
1111

12+
if not sys.platform.startswith("win"):
13+
import sh
14+
1215

1316
@pytest.mark.parametrize(
1417
"output_format,content,expected",
@@ -173,6 +176,9 @@ def test_set_no_file(cli):
173176
assert "Missing argument" in result.output
174177

175178

179+
@pytest.mark.skipif(
180+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
181+
)
176182
def test_get_default_path(tmp_path):
177183
with sh.pushd(tmp_path):
178184
(tmp_path / ".env").write_text("a=b")
@@ -182,6 +188,9 @@ def test_get_default_path(tmp_path):
182188
assert result == "b\n"
183189

184190

191+
@pytest.mark.skipif(
192+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
193+
)
185194
def test_run(tmp_path):
186195
with sh.pushd(tmp_path):
187196
(tmp_path / ".env").write_text("a=b")
@@ -191,6 +200,9 @@ def test_run(tmp_path):
191200
assert result == "b\n"
192201

193202

203+
@pytest.mark.skipif(
204+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
205+
)
194206
def test_run_with_existing_variable(tmp_path):
195207
with sh.pushd(tmp_path):
196208
(tmp_path / ".env").write_text("a=b")
@@ -202,6 +214,9 @@ def test_run_with_existing_variable(tmp_path):
202214
assert result == "b\n"
203215

204216

217+
@pytest.mark.skipif(
218+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
219+
)
205220
def test_run_with_existing_variable_not_overridden(tmp_path):
206221
with sh.pushd(tmp_path):
207222
(tmp_path / ".env").write_text("a=b")
@@ -213,6 +228,9 @@ def test_run_with_existing_variable_not_overridden(tmp_path):
213228
assert result == "c\n"
214229

215230

231+
@pytest.mark.skipif(
232+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
233+
)
216234
def test_run_with_none_value(tmp_path):
217235
with sh.pushd(tmp_path):
218236
(tmp_path / ".env").write_text("a=b\nc")
@@ -222,6 +240,9 @@ def test_run_with_none_value(tmp_path):
222240
assert result == "b\n"
223241

224242

243+
@pytest.mark.skipif(
244+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
245+
)
225246
def test_run_with_other_env(dotenv_path):
226247
dotenv_path.write_text("a=b")
227248

tests/test_main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from unittest import mock
77

88
import pytest
9-
import sh
109

1110
import dotenv
1211

12+
if not sys.platform.startswith("win"):
13+
import sh
14+
1315

1416
def test_set_key_no_file(tmp_path):
1517
nx_path = tmp_path / "nx"
@@ -456,6 +458,9 @@ def test_load_dotenv_file_stream(dotenv_path):
456458
assert os.environ == {"a": "b"}
457459

458460

461+
@pytest.mark.skipif(
462+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
463+
)
459464
def test_load_dotenv_in_current_dir(tmp_path):
460465
dotenv_path = tmp_path / ".env"
461466
dotenv_path.write_bytes(b"a=b")

tests/test_zip_imports.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from unittest import mock
66
from zipfile import ZipFile
77

8-
import sh
8+
import pytest
9+
10+
if not sys.platform.startswith("win"):
11+
import sh
912

1013

1114
def walk_to_root(path: str):
@@ -62,6 +65,9 @@ def test_load_dotenv_gracefully_handles_zip_imports_when_no_env_file(tmp_path):
6265
import child1.child2.test # noqa
6366

6467

68+
@pytest.mark.skipif(
69+
sys.platform.startswith("win"), reason="sh module doesn't support Windows"
70+
)
6571
def test_load_dotenv_outside_zip_file_when_called_in_zipfile(tmp_path):
6672
zip_file_path = setup_zipfile(
6773
tmp_path,

0 commit comments

Comments
 (0)