Skip to content

Commit f5ade42

Browse files
committed
Fix failed tests due to subtle changes in Python 3.11
1 parent a262a0f commit f5ade42

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tests/test_config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,12 @@ def test_proto(self):
12481248
self.assertEqual(cm.exception.args, ('Wrong value type: uint32',))
12491249
self.proto.Clear()
12501250
self.proto.options['option_name'].as_uint64 = 1000
1251-
with self.assertRaises(ValueError) as cm:
1252-
opt.load_proto(self.proto)
1253-
self.assertEqual(cm.exception.args, ("Illegal value 'SimpleIntFlag.512|256|128|64|32|FOUR' for flag option 'option_name'",))
1251+
# Python 3.11 changed how flag boundaries are checked, default is more benevolent
1252+
# see https://docs.python.org/3.11/library/enum.html#enum.FlagBoundary.KEEP
1253+
if int(platform.python_version_tuple()[1]) < 11:
1254+
with self.assertRaises(ValueError) as cm:
1255+
opt.load_proto(self.proto)
1256+
self.assertEqual(cm.exception.args, ("Illegal value 'SimpleIntFlag.512|256|128|64|32|FOUR' for flag option 'option_name'",))
12541257
self.proto.Clear()
12551258
opt.clear(to_default=False)
12561259
opt.save_proto(self.proto)

tests/test_logging.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
from __future__ import annotations
4040
import unittest
41+
import platform
4142
from logging import getLogger, Formatter, lastResort, LogRecord
4243
from firebird.base.types import *
4344
from firebird.base.logging import logging_manager, get_logger, bind_logger, \
@@ -78,6 +79,10 @@ def test_module(self):
7879
self.assertIsNotNone(lastResort)
7980
self.assertIsNotNone(lastResort.formatter)
8081
def test_aaa(self):
82+
if int(platform.python_version_tuple()[1]) < 11:
83+
AGENT = 'test_aaa (test_logging.TestLogging)'
84+
else:
85+
AGENT = 'test_aaa (test_logging.TestLogging.test_aaa)'
8186
# root
8287
with self.assertLogs() as log:
8388
get_logger(self).info('Message')
@@ -89,7 +94,7 @@ def test_aaa(self):
8994
self.assertEqual(rec.filename, 'test_logging.py')
9095
self.assertEqual(rec.funcName, 'test_aaa')
9196
self.assertEqual(rec.topic, '')
92-
self.assertEqual(rec.agent, 'test_aaa (test_logging.TestLogging)')
97+
self.assertEqual(rec.agent, AGENT)
9398
self.assertEqual(rec.context, UNDEFINED)
9499
self.assertEqual(rec.message, 'Message')
95100
# trace
@@ -103,7 +108,7 @@ def test_aaa(self):
103108
self.assertEqual(rec.filename, 'test_logging.py')
104109
self.assertEqual(rec.funcName, 'test_aaa')
105110
self.assertEqual(rec.topic, 'trace')
106-
self.assertEqual(rec.agent, 'test_aaa (test_logging.TestLogging)')
111+
self.assertEqual(rec.agent, AGENT)
107112
self.assertEqual(rec.context, UNDEFINED)
108113
self.assertEqual(rec.message, 'Message')
109114
def test_interpolation(self):

0 commit comments

Comments
 (0)