Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
csm10495 committed Apr 5, 2023
1 parent 2675990 commit ec6b246
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,16 @@ def test_soft_errors(tmp_path: Path, mocker: MockerFixture) -> None:


@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
def test_thrashing_with_threadpool_passing_lock_to_threads(tmp_path: Path, lock_type: BaseFileLock) -> None:
def test_thrashing_with_thread_pool_passing_lock_to_threads(tmp_path: Path, lock_type: BaseFileLock) -> None:
lock_file = tmp_path / "test.txt.lock"
txt_file = tmp_path / "test.txt"

# notice how lock is passed to the function below
lock = lock_type(lock_file)

def mess_with_file(lock, txt_file):
def mess_with_file(lock: BaseFileLock, txt_file: Path):
with lock:
for _ in range (3):
for _ in range(3):
u = str(uuid4())
txt_file.write_text(u)
assert txt_file.read_text() == u
Expand All @@ -539,16 +539,16 @@ def mess_with_file(lock, txt_file):


@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
def test_thrashing_with_threadpool_global_lock(tmp_path: Path, lock_type: BaseFileLock) -> None:
def test_thrashing_with_thread_pool_global_lock(tmp_path: Path, lock_type: BaseFileLock) -> None:
lock_file = tmp_path / "test.txt.lock"
txt_file = tmp_path / "test.txt"

# Notice how lock is scoped to be allowed in the nested function below
lock = lock_type(lock_file)

def mess_with_file(txt_file):
def mess_with_file(txt_file: Path):
with lock:
for _ in range (3):
for _ in range(3):
u = str(uuid4())
txt_file.write_text(u)
assert txt_file.read_text() == u
Expand All @@ -564,13 +564,13 @@ def mess_with_file(txt_file):


@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
def test_thrashing_with_threadpool_lock_recreated_in_each_thread(tmp_path: Path, lock_type: BaseFileLock) -> None:
def test_thrashing_with_thread_pool_lock_recreated_in_each_thread(tmp_path: Path, lock_type: BaseFileLock) -> None:
lock_file = tmp_path / "test.txt.lock"
txt_file = tmp_path / "test.txt"

def mess_with_file(lock_type, lock_file, txt_file):
def mess_with_file(lock_type: type, lock_file: Path, txt_file: Path):
with lock_type(lock_file):
for _ in range (3):
for _ in range(3):
u = str(uuid4())
txt_file.write_text(u)
assert txt_file.read_text() == u
Expand Down

0 comments on commit ec6b246

Please sign in to comment.