jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340533?usp=email )
Change subject: tests: Check EBADF in editor descriptor test
......................................................................
tests: Check EBADF in editor descriptor test
On Windows with Python 3.11, os.fstat() on the closed temporary
descriptor raises WinError 6 instead of Errno 9. The descriptor
check fails because it only matches the POSIX error message.
Both errors expose errno.EBADF through the exception's errno
attribute. Check this single code to verify the closed-descriptor
error independently of the platform-specific message.
Bug: T154281
Change-Id: I23062c662b6f01a43bc41782f0cd73bfe9296fa9
---
M tests/editor_tests.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Mahveotm: Looks good to me, approved
diff --git a/tests/editor_tests.py b/tests/editor_tests.py
index aed70e1..c792838 100755
--- a/tests/editor_tests.py
+++ b/tests/editor_tests.py
@@ -7,6 +7,7 @@
"""Tests for :mod:`editor` module."""
from __future__ import annotations
+import errno
import os
import unittest
from contextlib import suppress
@@ -65,9 +66,9 @@
return handle, filename
def run(*args, **kwargs):
- with self.assertRaisesRegex(
- OSError, r'\[Errno 9\] Bad file descriptor'):
+ with self.assertRaises(OSError) as cm:
os.fstat(handle)
+ self.assertEqual(cm.exception.errno, errno.EBADF)
with patch.object(editor.tempfile, 'mkstemp', side_effect=mkstemp):
with patch.object(editor.subprocess, 'run', side_effect=run):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340533?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I23062c662b6f01a43bc41782f0cd73bfe9296fa9
Gerrit-Change-Number: 1340533
Gerrit-PatchSet: 3
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mahveotm <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Xqt <[email protected]>
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]