test_encoder.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  5. # License: https://pyasn1.readthedocs.io/en/latest/license.html
  6. #
  7. import sys
  8. import unittest
  9. from __tests__.base import BaseTestCase
  10. from pyasn1.type import tag
  11. from pyasn1.type import namedtype
  12. from pyasn1.type import opentype
  13. from pyasn1.type import univ
  14. from pyasn1.codec.der import encoder
  15. from pyasn1.compat.octets import ints2octs
  16. class OctetStringEncoderTestCase(BaseTestCase):
  17. def testDefModeShort(self):
  18. assert encoder.encode(
  19. univ.OctetString('Quick brown fox')
  20. ) == ints2octs((4, 15, 81, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120))
  21. def testDefModeLong(self):
  22. assert encoder.encode(
  23. univ.OctetString('Q' * 10000)
  24. ) == ints2octs((4, 130, 39, 16) + (81,) * 10000)
  25. class BitStringEncoderTestCase(BaseTestCase):
  26. def testDefModeShort(self):
  27. assert encoder.encode(
  28. univ.BitString((1,))
  29. ) == ints2octs((3, 2, 7, 128))
  30. def testDefModeLong(self):
  31. assert encoder.encode(
  32. univ.BitString((1,) * 80000)
  33. ) == ints2octs((3, 130, 39, 17, 0) + (255,) * 10000)
  34. class SetOfEncoderTestCase(BaseTestCase):
  35. def setUp(self):
  36. BaseTestCase.setUp(self)
  37. self.s = univ.SetOf(componentType=univ.OctetString())
  38. def testDefMode1(self):
  39. self.s.clear()
  40. self.s.append('a')
  41. self.s.append('ab')
  42. assert encoder.encode(self.s) == ints2octs((49, 7, 4, 1, 97, 4, 2, 97, 98))
  43. def testDefMode2(self):
  44. self.s.clear()
  45. self.s.append('ab')
  46. self.s.append('a')
  47. assert encoder.encode(self.s) == ints2octs((49, 7, 4, 1, 97, 4, 2, 97, 98))
  48. def testDefMode3(self):
  49. self.s.clear()
  50. self.s.append('b')
  51. self.s.append('a')
  52. assert encoder.encode(self.s) == ints2octs((49, 6, 4, 1, 97, 4, 1, 98))
  53. def testDefMode4(self):
  54. self.s.clear()
  55. self.s.append('a')
  56. self.s.append('b')
  57. assert encoder.encode(self.s) == ints2octs((49, 6, 4, 1, 97, 4, 1, 98))
  58. class SetWithAlternatingChoiceEncoderTestCase(BaseTestCase):
  59. def setUp(self):
  60. BaseTestCase.setUp(self)
  61. c = univ.Choice(componentType=namedtype.NamedTypes(
  62. namedtype.NamedType('name', univ.OctetString()),
  63. namedtype.NamedType('amount', univ.Boolean()))
  64. )
  65. self.s = univ.Set(componentType=namedtype.NamedTypes(
  66. namedtype.NamedType('value', univ.Integer(5)),
  67. namedtype.NamedType('status', c))
  68. )
  69. def testComponentsOrdering1(self):
  70. self.s.setComponentByName('status')
  71. self.s.getComponentByName('status').setComponentByPosition(0, 'A')
  72. assert encoder.encode(self.s) == ints2octs((49, 6, 2, 1, 5, 4, 1, 65))
  73. def testComponentsOrdering2(self):
  74. self.s.setComponentByName('status')
  75. self.s.getComponentByName('status').setComponentByPosition(1, True)
  76. assert encoder.encode(self.s) == ints2octs((49, 6, 1, 1, 255, 2, 1, 5))
  77. class SetWithTaggedChoiceEncoderTestCase(BaseTestCase):
  78. def testWithUntaggedChoice(self):
  79. c = univ.Choice(
  80. componentType=namedtype.NamedTypes(
  81. namedtype.NamedType('premium', univ.Boolean())
  82. )
  83. )
  84. s = univ.Set(
  85. componentType=namedtype.NamedTypes(
  86. namedtype.NamedType('name', univ.OctetString()),
  87. namedtype.NamedType('customer', c)
  88. )
  89. )
  90. s.setComponentByName('name', 'A')
  91. s.getComponentByName('customer').setComponentByName('premium', True)
  92. assert encoder.encode(s) == ints2octs((49, 6, 1, 1, 255, 4, 1, 65))
  93. def testWithTaggedChoice(self):
  94. c = univ.Choice(
  95. componentType=namedtype.NamedTypes(
  96. namedtype.NamedType('premium', univ.Boolean())
  97. )
  98. ).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7))
  99. s = univ.Set(
  100. componentType=namedtype.NamedTypes(
  101. namedtype.NamedType('name', univ.OctetString()),
  102. namedtype.NamedType('customer', c)
  103. )
  104. )
  105. s.setComponentByName('name', 'A')
  106. s.getComponentByName('customer').setComponentByName('premium', True)
  107. assert encoder.encode(s) == ints2octs((49, 8, 4, 1, 65, 167, 3, 1, 1, 255))
  108. class SequenceEncoderWithUntaggedOpenTypesTestCase(BaseTestCase):
  109. def setUp(self):
  110. BaseTestCase.setUp(self)
  111. openType = opentype.OpenType(
  112. 'id',
  113. {1: univ.Integer(),
  114. 2: univ.OctetString()}
  115. )
  116. self.s = univ.Sequence(
  117. componentType=namedtype.NamedTypes(
  118. namedtype.NamedType('id', univ.Integer()),
  119. namedtype.NamedType('blob', univ.Any(), openType=openType)
  120. )
  121. )
  122. def testEncodeOpenTypeChoiceOne(self):
  123. self.s.clear()
  124. self.s[0] = 1
  125. self.s[1] = univ.Integer(12)
  126. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  127. (48, 5, 2, 1, 1, 49, 50)
  128. )
  129. def testEncodeOpenTypeChoiceTwo(self):
  130. self.s.clear()
  131. self.s[0] = 2
  132. self.s[1] = univ.OctetString('quick brown')
  133. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  134. (48, 14, 2, 1, 2, 113, 117, 105, 99, 107, 32,
  135. 98, 114, 111, 119, 110)
  136. )
  137. def testEncodeOpenTypeUnknownId(self):
  138. self.s.clear()
  139. self.s[0] = 2
  140. self.s[1] = univ.ObjectIdentifier('1.3.6')
  141. try:
  142. encoder.encode(self.s, asn1Spec=self.s)
  143. except PyAsn1Error:
  144. assert False, 'incompatible open type tolerated'
  145. def testEncodeOpenTypeIncompatibleType(self):
  146. self.s.clear()
  147. self.s[0] = 2
  148. self.s[1] = univ.ObjectIdentifier('1.3.6')
  149. try:
  150. encoder.encode(self.s, asn1Spec=self.s)
  151. except PyAsn1Error:
  152. assert False, 'incompatible open type tolerated'
  153. class SequenceEncoderWithImplicitlyTaggedOpenTypesTestCase(BaseTestCase):
  154. def setUp(self):
  155. BaseTestCase.setUp(self)
  156. openType = opentype.OpenType(
  157. 'id',
  158. {1: univ.Integer(),
  159. 2: univ.OctetString()}
  160. )
  161. self.s = univ.Sequence(
  162. componentType=namedtype.NamedTypes(
  163. namedtype.NamedType('id', univ.Integer()),
  164. namedtype.NamedType('blob', univ.Any().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)), openType=openType)
  165. )
  166. )
  167. def testEncodeOpenTypeChoiceOne(self):
  168. self.s.clear()
  169. self.s[0] = 1
  170. self.s[1] = univ.Integer(12)
  171. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  172. (48, 9, 2, 1, 1, 131, 4, 131, 2, 49, 50)
  173. )
  174. class SequenceEncoderWithExplicitlyTaggedOpenTypesTestCase(BaseTestCase):
  175. def setUp(self):
  176. BaseTestCase.setUp(self)
  177. openType = opentype.OpenType(
  178. 'id',
  179. {1: univ.Integer(),
  180. 2: univ.OctetString()}
  181. )
  182. self.s = univ.Sequence(
  183. componentType=namedtype.NamedTypes(
  184. namedtype.NamedType('id', univ.Integer()),
  185. namedtype.NamedType('blob', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)), openType=openType)
  186. )
  187. )
  188. def testEncodeOpenTypeChoiceOne(self):
  189. self.s.clear()
  190. self.s[0] = 1
  191. self.s[1] = univ.Integer(12)
  192. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  193. (48, 9, 2, 1, 1, 163, 4, 163, 2, 49, 50)
  194. )
  195. class SequenceEncoderWithUntaggedSetOfOpenTypesTestCase(BaseTestCase):
  196. def setUp(self):
  197. BaseTestCase.setUp(self)
  198. openType = opentype.OpenType(
  199. 'id',
  200. {1: univ.Integer(),
  201. 2: univ.OctetString()}
  202. )
  203. self.s = univ.Sequence(
  204. componentType=namedtype.NamedTypes(
  205. namedtype.NamedType('id', univ.Integer()),
  206. namedtype.NamedType('blob', univ.SetOf(
  207. componentType=univ.Any()), openType=openType)
  208. )
  209. )
  210. def testEncodeOpenTypeChoiceOne(self):
  211. self.s.clear()
  212. self.s[0] = 1
  213. self.s[1].append(univ.Integer(12))
  214. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  215. (48, 7, 2, 1, 1, 49, 2, 49, 50)
  216. )
  217. def testEncodeOpenTypeChoiceTwo(self):
  218. self.s.clear()
  219. self.s[0] = 2
  220. self.s[1].append(univ.OctetString('quick brown'))
  221. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  222. (48, 16, 2, 1, 2, 49, 11, 113, 117, 105, 99, 107, 32, 98, 114,
  223. 111, 119, 110)
  224. )
  225. def testEncodeOpenTypeUnknownId(self):
  226. self.s.clear()
  227. self.s[0] = 2
  228. self.s[1].append(univ.ObjectIdentifier('1.3.6'))
  229. try:
  230. encoder.encode(self.s, asn1Spec=self.s)
  231. except PyAsn1Error:
  232. assert False, 'incompatible open type tolerated'
  233. def testEncodeOpenTypeIncompatibleType(self):
  234. self.s.clear()
  235. self.s[0] = 2
  236. self.s[1].append(univ.ObjectIdentifier('1.3.6'))
  237. try:
  238. encoder.encode(self.s, asn1Spec=self.s)
  239. except PyAsn1Error:
  240. assert False, 'incompatible open type tolerated'
  241. class SequenceEncoderWithImplicitlyTaggedSetOfOpenTypesTestCase(BaseTestCase):
  242. def setUp(self):
  243. BaseTestCase.setUp(self)
  244. openType = opentype.OpenType(
  245. 'id',
  246. {1: univ.Integer(),
  247. 2: univ.OctetString()}
  248. )
  249. self.s = univ.Sequence(
  250. componentType=namedtype.NamedTypes(
  251. namedtype.NamedType('id', univ.Integer()),
  252. namedtype.NamedType('blob', univ.SetOf(
  253. componentType=univ.Any().subtype(
  254. implicitTag=tag.Tag(
  255. tag.tagClassContext, tag.tagFormatSimple, 3))),
  256. openType=openType)
  257. )
  258. )
  259. def testEncodeOpenTypeChoiceOne(self):
  260. self.s.clear()
  261. self.s[0] = 1
  262. self.s[1].append(univ.Integer(12))
  263. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  264. (48, 11, 2, 1, 1, 49, 6, 131, 4, 131, 2, 49, 50)
  265. )
  266. class SequenceEncoderWithExplicitlyTaggedSetOfOpenTypesTestCase(BaseTestCase):
  267. def setUp(self):
  268. BaseTestCase.setUp(self)
  269. openType = opentype.OpenType(
  270. 'id',
  271. {1: univ.Integer(),
  272. 2: univ.OctetString()}
  273. )
  274. self.s = univ.Sequence(
  275. componentType=namedtype.NamedTypes(
  276. namedtype.NamedType('id', univ.Integer()),
  277. namedtype.NamedType('blob', univ.SetOf(
  278. componentType=univ.Any().subtype(
  279. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  280. openType=openType)
  281. )
  282. )
  283. def testEncodeOpenTypeChoiceOne(self):
  284. self.s.clear()
  285. self.s[0] = 1
  286. self.s[1].append(univ.Integer(12))
  287. assert encoder.encode(self.s, asn1Spec=self.s) == ints2octs(
  288. (48, 11, 2, 1, 1, 49, 6, 163, 4, 163, 2, 49, 50)
  289. )
  290. class NestedOptionalSequenceEncoderTestCase(BaseTestCase):
  291. def setUp(self):
  292. BaseTestCase.setUp(self)
  293. inner = univ.Sequence(
  294. componentType=namedtype.NamedTypes(
  295. namedtype.OptionalNamedType('first-name', univ.OctetString()),
  296. namedtype.DefaultedNamedType('age', univ.Integer(33)),
  297. )
  298. )
  299. outerWithOptional = univ.Sequence(
  300. componentType=namedtype.NamedTypes(
  301. namedtype.OptionalNamedType('inner', inner),
  302. )
  303. )
  304. outerWithDefault = univ.Sequence(
  305. componentType=namedtype.NamedTypes(
  306. namedtype.DefaultedNamedType('inner', inner),
  307. )
  308. )
  309. self.s1 = outerWithOptional
  310. self.s2 = outerWithDefault
  311. def __initOptionalWithDefaultAndOptional(self):
  312. self.s1.clear()
  313. self.s1[0][0] = 'test'
  314. self.s1[0][1] = 123
  315. return self.s1
  316. def __initOptionalWithDefault(self):
  317. self.s1.clear()
  318. self.s1[0][1] = 123
  319. return self.s1
  320. def __initOptionalWithOptional(self):
  321. self.s1.clear()
  322. self.s1[0][0] = 'test'
  323. return self.s1
  324. def __initOptional(self):
  325. self.s1.clear()
  326. return self.s1
  327. def __initDefaultWithDefaultAndOptional(self):
  328. self.s2.clear()
  329. self.s2[0][0] = 'test'
  330. self.s2[0][1] = 123
  331. return self.s2
  332. def __initDefaultWithDefault(self):
  333. self.s2.clear()
  334. self.s2[0][0] = 'test'
  335. return self.s2
  336. def __initDefaultWithOptional(self):
  337. self.s2.clear()
  338. self.s2[0][1] = 123
  339. return self.s2
  340. def testDefModeOptionalWithDefaultAndOptional(self):
  341. s = self.__initOptionalWithDefaultAndOptional()
  342. assert encoder.encode(s) == ints2octs((48, 11, 48, 9, 4, 4, 116, 101, 115, 116, 2, 1, 123))
  343. def testDefModeOptionalWithDefault(self):
  344. s = self.__initOptionalWithDefault()
  345. assert encoder.encode(s) == ints2octs((48, 5, 48, 3, 2, 1, 123))
  346. def testDefModeOptionalWithOptional(self):
  347. s = self.__initOptionalWithOptional()
  348. assert encoder.encode(s) == ints2octs((48, 8, 48, 6, 4, 4, 116, 101, 115, 116))
  349. def testDefModeOptional(self):
  350. s = self.__initOptional()
  351. assert encoder.encode(s) == ints2octs((48, 0))
  352. def testDefModeDefaultWithDefaultAndOptional(self):
  353. s = self.__initDefaultWithDefaultAndOptional()
  354. assert encoder.encode(s) == ints2octs((48, 11, 48, 9, 4, 4, 116, 101, 115, 116, 2, 1, 123))
  355. def testDefModeDefaultWithDefault(self):
  356. s = self.__initDefaultWithDefault()
  357. assert encoder.encode(s) == ints2octs((48, 8, 48, 6, 4, 4, 116, 101, 115, 116))
  358. def testDefModeDefaultWithOptional(self):
  359. s = self.__initDefaultWithOptional()
  360. assert encoder.encode(s) == ints2octs((48, 5, 48, 3, 2, 1, 123))
  361. class NestedOptionalChoiceEncoderTestCase(BaseTestCase):
  362. def setUp(self):
  363. BaseTestCase.setUp(self)
  364. layer3 = univ.Sequence(
  365. componentType=namedtype.NamedTypes(
  366. namedtype.OptionalNamedType('first-name', univ.OctetString()),
  367. namedtype.DefaultedNamedType('age', univ.Integer(33)),
  368. )
  369. )
  370. layer2 = univ.Choice(
  371. componentType=namedtype.NamedTypes(
  372. namedtype.NamedType('inner', layer3),
  373. namedtype.NamedType('first-name', univ.OctetString())
  374. )
  375. )
  376. layer1 = univ.Sequence(
  377. componentType=namedtype.NamedTypes(
  378. namedtype.OptionalNamedType('inner', layer2),
  379. )
  380. )
  381. self.s = layer1
  382. def __initOptionalWithDefaultAndOptional(self):
  383. self.s.clear()
  384. self.s[0][0][0] = 'test'
  385. self.s[0][0][1] = 123
  386. return self.s
  387. def __initOptionalWithDefault(self):
  388. self.s.clear()
  389. self.s[0][0][1] = 123
  390. return self.s
  391. def __initOptionalWithOptional(self):
  392. self.s.clear()
  393. self.s[0][0][0] = 'test'
  394. return self.s
  395. def __initOptional(self):
  396. self.s.clear()
  397. return self.s
  398. def testDefModeOptionalWithDefaultAndOptional(self):
  399. s = self.__initOptionalWithDefaultAndOptional()
  400. assert encoder.encode(s) == ints2octs((48, 11, 48, 9, 4, 4, 116, 101, 115, 116, 2, 1, 123))
  401. def testDefModeOptionalWithDefault(self):
  402. s = self.__initOptionalWithDefault()
  403. assert encoder.encode(s) == ints2octs((48, 5, 48, 3, 2, 1, 123))
  404. def testDefModeOptionalWithOptional(self):
  405. s = self.__initOptionalWithOptional()
  406. assert encoder.encode(s) == ints2octs((48, 8, 48, 6, 4, 4, 116, 101, 115, 116))
  407. def testDefModeOptional(self):
  408. s = self.__initOptional()
  409. assert encoder.encode(s) == ints2octs((48, 0))
  410. class NestedOptionalSequenceOfEncoderTestCase(BaseTestCase):
  411. def setUp(self):
  412. BaseTestCase.setUp(self)
  413. layer2 = univ.SequenceOf(
  414. componentType=univ.OctetString()
  415. )
  416. layer1 = univ.Sequence(
  417. componentType=namedtype.NamedTypes(
  418. namedtype.OptionalNamedType('inner', layer2),
  419. )
  420. )
  421. self.s = layer1
  422. def __initOptionalWithValue(self):
  423. self.s.clear()
  424. self.s[0][0] = 'test'
  425. return self.s
  426. def __initOptional(self):
  427. self.s.clear()
  428. return self.s
  429. def testDefModeOptionalWithValue(self):
  430. s = self.__initOptionalWithValue()
  431. assert encoder.encode(s) == ints2octs((48, 8, 48, 6, 4, 4, 116, 101, 115, 116))
  432. def testDefModeOptional(self):
  433. s = self.__initOptional()
  434. assert encoder.encode(s) == ints2octs((48, 0))
  435. class EmptyInnerFieldOfSequenceEncoderTestCase(BaseTestCase):
  436. def testInitializedOptionalNullIsEncoded(self):
  437. self.s = univ.Sequence(
  438. componentType=namedtype.NamedTypes(
  439. namedtype.OptionalNamedType('null', univ.Null())
  440. )
  441. )
  442. self.s.clear()
  443. self.s[0] = ''
  444. assert encoder.encode(self.s) == ints2octs((48, 2, 5, 0))
  445. def testUninitializedOptionalNullIsNotEncoded(self):
  446. self.s = univ.Sequence(
  447. componentType=namedtype.NamedTypes(
  448. namedtype.OptionalNamedType('null', univ.Null())
  449. )
  450. )
  451. self.s.clear()
  452. assert encoder.encode(self.s) == ints2octs((48, 0))
  453. def testInitializedDefaultNullIsNotEncoded(self):
  454. self.s = univ.Sequence(
  455. componentType=namedtype.NamedTypes(
  456. namedtype.DefaultedNamedType('null', univ.Null(''))
  457. )
  458. )
  459. self.s.clear()
  460. self.s[0] = ''
  461. assert encoder.encode(self.s) == ints2octs((48, 0))
  462. def testInitializedOptionalOctetStringIsEncoded(self):
  463. self.s = univ.Sequence(
  464. componentType=namedtype.NamedTypes(
  465. namedtype.OptionalNamedType('str', univ.OctetString())
  466. )
  467. )
  468. self.s.clear()
  469. self.s[0] = ''
  470. assert encoder.encode(self.s) == ints2octs((48, 2, 4, 0))
  471. def testUninitializedOptionalOctetStringIsNotEncoded(self):
  472. self.s = univ.Sequence(
  473. componentType=namedtype.NamedTypes(
  474. namedtype.OptionalNamedType('str', univ.OctetString())
  475. )
  476. )
  477. self.s.clear()
  478. assert encoder.encode(self.s) == ints2octs((48, 0))
  479. def testInitializedDefaultOctetStringIsNotEncoded(self):
  480. self.s = univ.Sequence(
  481. componentType=namedtype.NamedTypes(
  482. namedtype.DefaultedNamedType('str', univ.OctetString(''))
  483. )
  484. )
  485. self.s.clear()
  486. self.s[0] = ''
  487. assert encoder.encode(self.s) == ints2octs((48, 0))
  488. class ClassConstructorTestCase(BaseTestCase):
  489. def testKeywords(self):
  490. tagmap = {"tagmap": True}
  491. typemap = {"typemap": True}
  492. sie = encoder.Encoder()._singleItemEncoder
  493. self.assertIs(sie._tagMap, encoder.TAG_MAP)
  494. self.assertIs(sie._typeMap, encoder.TYPE_MAP)
  495. sie = encoder.Encoder(
  496. tagMap=tagmap, typeMap=typemap
  497. )._singleItemEncoder
  498. self.assertIs(sie._tagMap, tagmap)
  499. self.assertIs(sie._typeMap, typemap)
  500. sie = encoder.Encoder(tagmap, typemap)._singleItemEncoder
  501. self.assertIs(sie._tagMap, tagmap)
  502. self.assertIs(sie._typeMap, typemap)
  503. suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
  504. if __name__ == '__main__':
  505. unittest.TextTestRunner(verbosity=2).run(suite)