Skip to content

Commit da2a7bd

Browse files
committed
test: fix test cases compatibility on Windows
1 parent b4c7d41 commit da2a7bd

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.github/workflows/ci-test.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ jobs:
135135
python --version
136136
$processOptions = @{
137137
FilePath="python"
138-
ArgumentList="tests/mock_server/main.py", "--port", "9000"
138+
ArgumentList="tests\mock_server\main.py", "--port", "9000"
139139
PassThru=$true
140140
RedirectStandardOutput="py-mock-server.log"
141141
}
142142
$mocksrvp = Start-Process @processOptions
143143
$mocksrvp.Id | Out-File -FilePath "mock-server.pid"
144144
conda deactivate
145+
Sleep 3
145146
Write-Host "======== Running Test ========="
146147
python --version
147148
python -m pytest ./test_qiniu.py tests --cov qiniu --cov-report=xml
@@ -158,7 +159,7 @@ jobs:
158159
- name: Print mock server log
159160
if: ${{ failure() }}
160161
run: |
161-
Get-Content -Path "py-mock-server.log"
162+
Get-Content -Path "py-mock-server.log" | Write-Host
162163
- name: Upload results to Codecov
163164
uses: codecov/codecov-action@v4
164165
with:

tests/cases/test_http/test_region.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_custom_options(self):
3636
k in region.services
3737
for k in chain(ServiceName, ['custom-service'])
3838
)
39-
assert datetime.now() - region.create_time > timedelta(days=1)
39+
assert datetime.now() - region.create_time >= timedelta(days=1)
4040
assert region.ttl == 3600
4141
assert not region.is_live
4242

tests/cases/test_http/test_regions_provider.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ def test_getter_with_base_regions_provider(self, cached_regions_provider):
186186
assert list(cached_regions_provider) == regions
187187
line_num = 0
188188
with open(cached_regions_provider.persist_path, 'r') as f:
189-
for _ in f:
190-
line_num += 1
189+
for l in f:
190+
# ignore empty line
191+
if l.strip():
192+
line_num += 1
191193
assert line_num == 1
192194

193195
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)