Skip to content

Commit 5f43e41

Browse files
Copilotcooperlees
andcommitted
Update tests to handle filelock 3.21.0+ behavior change
Filelock 3.21.0 introduced automatic deletion of lock files on release for Unix systems. Updated test expectations to not include .lock file on non-Windows platforms, as the lock file is now cleaned up after release. This aligns with standard Unix lock file behavior. Co-authored-by: cooperlees <3005596+cooperlees@users.noreply.github.com>
1 parent 7574a44 commit 5f43e41

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/bandersnatch/tests/plugins/test_storage_plugins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ class BaseStoragePluginTestCase(BasePluginTestCase):
192192
web{0}simple{0}foobar
193193
web{0}simple{0}foobar{0}index.html
194194
web{0}simple{0}index.html""".format(os.sep).strip()
195-
if sys.platform == "win32":
195+
if sys.platform != "win32":
196+
# filelock 3.21.0+ deletes lock file on release on Unix systems
196197
base_find_contents = base_find_contents.replace(".lock\n", "")
197198

198199
def test_plugin_type(self) -> None:

src/bandersnatch/tests/test_mirror.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ async def test_mirror_empty_resume_from_todo_list(mirror: BandersnatchMirror) ->
290290
web{0}simple{0}index.html
291291
web{0}simple{0}index.v1_html
292292
web{0}simple{0}index.v1_json""".format(sep)
293-
if WINDOWS:
293+
if not WINDOWS:
294+
# filelock 3.21.0+ deletes lock file on release on Unix systems
294295
expected = expected.replace(".lock\n", "")
295296
assert expected == utils.find(mirror.homedir)
296297

@@ -382,7 +383,8 @@ async def test_mirror_sync_package_error_no_early_exit(
382383
web{0}simple{0}index.html
383384
web{0}simple{0}index.v1_html
384385
web{0}simple{0}index.v1_json""".format(sep)
385-
if WINDOWS:
386+
if not WINDOWS:
387+
# filelock 3.21.0+ deletes lock file on release on Unix systems
386388
expected = expected.replace(".lock\n", "")
387389
assert expected == utils.find(mirror.homedir, dirs=False)
388390
assert open("web{0}simple{0}index.html".format(sep)).read() == """\
@@ -421,13 +423,17 @@ async def mirror_sync_package_error_early_exit(mirror: BandersnatchMirror) -> No
421423
with pytest.raises(SystemExit):
422424
await mirror.synchronize()
423425

424-
assert """\
426+
expected = """\
425427
.lock
426428
generation
427429
todo
428430
web{0}packages{0}any{0}f{0}foo{0}foo.zip
429431
web{0}simple{0}foo{0}index.html
430-
web{0}simple{0}index.html""".format(sep) == utils.find(mirror.homedir, dirs=False)
432+
web{0}simple{0}index.html""".format(sep)
433+
if not WINDOWS:
434+
# filelock 3.21.0+ deletes lock file on release on Unix systems
435+
expected = expected.replace(".lock\n", "")
436+
assert expected == utils.find(mirror.homedir, dirs=False)
431437
assert open("web{0}simple{0}index.html".format(sep)).read() == "old index"
432438
assert open("todo").read() == "1\n"
433439

0 commit comments

Comments
 (0)