mirror of
https://github.com/lutris/lutris.git
synced 2026-06-17 18:29:58 -04:00
Fix test failures in PR #6525 cloud sync tests
- Replace object.__new__() with CloudSyncProgressDialog.__new__() to fix Python 3.13+ compatibility (object.__new__ rejects classes whose __init__ takes extra parameters) - Gzip-compress mock response data in download_file tests to match the actual gzip.decompress() call in the implementation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -111,7 +111,7 @@ class TestCloudSyncProgressDialogInit(unittest.TestCase):
|
||||
def _make_dialog(self, direction="pre-launch"):
|
||||
game = _make_game()
|
||||
sync_func = MagicMock(return_value=[])
|
||||
dialog = object.__new__(CloudSyncProgressDialog)
|
||||
dialog = CloudSyncProgressDialog.__new__(CloudSyncProgressDialog)
|
||||
dialog.game = game
|
||||
dialog._sync_func = sync_func
|
||||
dialog._direction = direction
|
||||
@@ -140,7 +140,7 @@ class TestCloudSyncProgressDialogRunSync(unittest.TestCase):
|
||||
def _make_dialog(self):
|
||||
game = _make_game()
|
||||
sync_func = MagicMock(return_value=[])
|
||||
dialog = object.__new__(CloudSyncProgressDialog)
|
||||
dialog = CloudSyncProgressDialog.__new__(CloudSyncProgressDialog)
|
||||
dialog.game = game
|
||||
dialog._sync_func = sync_func
|
||||
dialog._direction = "pre-launch"
|
||||
@@ -173,7 +173,7 @@ class TestCloudSyncProgressDialogCallbacks(unittest.TestCase):
|
||||
"""Create a dialog with all GTK interactions mocked out."""
|
||||
game = _make_game()
|
||||
sync_func = MagicMock(return_value=[])
|
||||
dialog = object.__new__(CloudSyncProgressDialog)
|
||||
dialog = CloudSyncProgressDialog.__new__(CloudSyncProgressDialog)
|
||||
dialog.game = game
|
||||
dialog._sync_func = sync_func
|
||||
dialog._direction = "pre-launch"
|
||||
@@ -281,7 +281,7 @@ class TestCloudSyncProgressDialogSkip(unittest.TestCase):
|
||||
def _make_dialog(self):
|
||||
game = _make_game()
|
||||
sync_func = MagicMock(return_value=[])
|
||||
dialog = object.__new__(CloudSyncProgressDialog)
|
||||
dialog = CloudSyncProgressDialog.__new__(CloudSyncProgressDialog)
|
||||
dialog.game = game
|
||||
dialog._sync_func = sync_func
|
||||
dialog._direction = "pre-launch"
|
||||
|
||||
@@ -301,7 +301,7 @@ class TestGOGCloudStorageClient(unittest.TestCase):
|
||||
|
||||
def test_download_file(self):
|
||||
mock_response = MagicMock()
|
||||
mock_response.read.return_value = b"save file content"
|
||||
mock_response.read.return_value = gzip.compress(b"save file content")
|
||||
mock_response.getheaders.return_value = [("X-Object-Meta-LocalLastModified", "2024-01-15T10:00:00+00:00")]
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
@@ -339,7 +339,7 @@ class TestGOGCloudStorageClient(unittest.TestCase):
|
||||
|
||||
def test_download_file_invalid_timestamp(self):
|
||||
mock_response = MagicMock()
|
||||
mock_response.read.return_value = b"data"
|
||||
mock_response.read.return_value = gzip.compress(b"data")
|
||||
mock_response.getheaders.return_value = [("X-Object-Meta-LocalLastModified", "not a date")]
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user