Skip to content

Commit a0afb1e

Browse files
committed
Adds testing on Windows to the GitHub action
1 parent 9966e58 commit a0afb1e

5 files changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ on:
1212
jobs:
1313
build:
1414

15-
runs-on: ubuntu-latest
1615
strategy:
1716
matrix:
1817
python-version: ["3.8", "3.9", "3.10"]
18+
os: [ ubuntu-latest, windows-latest ]
19+
runs-on: ${{matrix.os}}
1920

2021
steps:
2122
- uses: actions/checkout@v3
@@ -25,5 +26,7 @@ jobs:
2526
python-version: ${{ matrix.python-version }}
2627
- name: Install testing environment and kegg_pull package
2728
run: bash dev/install.sh
29+
shell: bash
2830
- name: Test with pytest
2931
run: bash dev/test.sh
32+
shell: bash

dev/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ echo "Removing previous .env/ directory if it exists..."
22
rm -rf .env/
33
echo "Creating new .env/ directory..."
44
python3 -m venv .env/
5-
source .env/bin/activate
5+
source .env/bin/activate || source .env/Scripts/activate # Windows has Scripts instead of bin
66
python3 -m pip install --upgrade pip
77
python3 -m pip install pytest pytest-mock pytest-cov sphinx sphinx-rtd-theme notebook
88
python3 -m pip install -e .

dev/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
source .env/bin/activate
1+
source .env/bin/activate || source .env/Scripts/activate # Windows has Scripts instead of bin
22

3-
python -m pytest dev --cov --cov-branch --cov-report=term-missing
3+
python3 -m pytest dev --cov --cov-branch --cov-report=term-missing

dev/test_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def test_main_pull(mocker, args: list, output: str):
160160

161161
# If running on Windows, change the actual files names to have underscores instead of colons.
162162
if os.name == 'nt': # pragma: no cover
163+
expected_output_files: list = expected_output_files[:-1] # The last brite gives different output on Windows
163164
successful_entry_ids: list = expected_output_files # pragma: no cover
164165

165166
for successful_entry_id, expected_output_file in zip(successful_entry_ids, expected_output_files):

src/kegg_pull/_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ def save_file(file_location: str, file_content: t.Union[str, bytes], file_name:
9090

9191
file_path: str = os.path.join(file_location, file_name)
9292
save_type: str = 'wb' if type(file_content) is bytes else 'w'
93+
encoding: t.Union[str, None] = None if type(file_content) is bytes else 'utf-8'
9394

94-
with open(file_path, save_type) as file:
95+
with open(file_path, save_type, encoding=encoding) as file:
9596
file.write(file_content)
9697

9798

0 commit comments

Comments
 (0)