@@ -90,12 +90,24 @@ def test_longestCommonPrefix(self):
9090 self .assertEqual (longestCommonPrefix ("abc" , "xyz" ), "" )
9191
9292 def test_decodeIntToUnicode (self ):
93- # single-byte code points map to their char
94- self .assertEqual (decodeIntToUnicode (65 ), u"A" )
95- self .assertEqual (decodeIntToUnicode (97 ), u"a" )
96- # NOTE: >255 ints are interpreted as a multi-byte sequence (not a Unicode code point),
97- # e.g. 0x2122 -> bytes 0x21 0x22 -> '!"' (documents actual behavior, not an assumption)
98- self .assertEqual (decodeIntToUnicode (0x2122 ), u'!"' )
93+ from lib .core .common import Backend
94+ from lib .core .data import kb
95+
96+ # decodeIntToUnicode() is back-end DBMS dependent (e.g. PostgreSQL/Oracle/SQLite
97+ # treat >255 values as Unicode code points). Pin a clean, no-forced-DBMS state so
98+ # the result is deterministic regardless of test execution order (a prior dialect
99+ # test may otherwise leave a forced DBMS set); restore it afterwards.
100+ _saved = (kb .get ("forcedDbms" ), kb .get ("stickyDBMS" ))
101+ Backend .flushForcedDbms (force = True )
102+ try :
103+ # single-byte code points map to their char
104+ self .assertEqual (decodeIntToUnicode (65 ), u"A" )
105+ self .assertEqual (decodeIntToUnicode (97 ), u"a" )
106+ # NOTE: with no identified DBMS, >255 ints are interpreted as a multi-byte
107+ # sequence (not a Unicode code point), e.g. 0x2122 -> bytes 0x21 0x22 -> '!"'
108+ self .assertEqual (decodeIntToUnicode (0x2122 ), u'!"' )
109+ finally :
110+ kb .forcedDbms , kb .stickyDBMS = _saved
99111
100112
101113if __name__ == "__main__" :
0 commit comments