Skip to content

Commit

Permalink
fix flaky test (#133)
Browse files Browse the repository at this point in the history
* fix flaky test

* fix py3.12

* qa

* sleep 0.2
  • Loading branch information
malmans2 authored Sep 9, 2024
1 parent 77610a3 commit a23a830
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ jobs:
include:
- python-version: '3.9'
extra: -ci
- python-version: '3.12'
extra: -ci
- python-version: '3.11'
extra: -integration

Expand Down
12 changes: 10 additions & 2 deletions tests/test_20_encode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import datetime
import pickle
from typing import Any

import pytest
Expand Down Expand Up @@ -100,11 +101,18 @@ def test_filecache_default_error(raise_all_encoding_errors: bool) -> None:
class Dummy:
pass

try:
pickle.dumps(Dummy)
except Exception as exc:
match = str(exc)
else:
raise ValueError("Did not raise!")

if raise_all_encoding_errors:
with pytest.raises(AttributeError, match="Can't pickle local object"):
with pytest.raises(AttributeError, match=match):
encode.filecache_default(Dummy())
else:
with pytest.warns(UserWarning, match="Can't pickle local object"):
with pytest.warns(UserWarning, match=match):
with pytest.raises(encode.EncodeError):
encode.filecache_default(Dummy())

Expand Down
2 changes: 1 addition & 1 deletion tests/test_50_io_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_io_locker(
fs.touch(file_path)
fs.touch(f"{file_path}.lock")

process = subprocess.Popen(f"sleep 0.1; rm {file_path}.lock", shell=True)
process = subprocess.Popen(f"sleep 0.2; rm {file_path}.lock", shell=True)
with raises_or_warns:
cached_open(tmpfile)
assert process.wait() == 0
Expand Down

0 comments on commit a23a830

Please sign in to comment.