1#!/usr/bin/env python 2# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD 3# SPDX-License-Identifier: Apache-2.0 4from __future__ import division, print_function 5 6import sys 7import unittest 8 9try: 10 import efuse_table_gen 11except ImportError: 12 sys.path.append('..') 13 import efuse_table_gen 14 15 16''' 17To run the test on local PC: 18cd ~/esp/esp-idf/components/efuse/test_efuse_host/ 19 ./efuse_tests.py 20''' 21 22 23class Py23TestCase(unittest.TestCase): 24 25 def __init__(self, *args, **kwargs): 26 super(Py23TestCase, self).__init__(*args, **kwargs) 27 try: 28 self.assertRaisesRegex 29 except AttributeError: 30 # assertRaisesRegexp is deprecated in Python3 but assertRaisesRegex doesn't exist in Python2 31 # This fix is used in order to avoid using the alias from the six library 32 self.assertRaisesRegex = self.assertRaisesRegexp 33 34 35class CSVParserTests(Py23TestCase): 36 37 def test_general(self): 38 csv = """ 39# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 40name1, EFUSE_BLK3, 0, 5, Use for test name 1 41name2, EFUSE_BLK3, 5, 4, Use for test name 2 42""" 43 t = efuse_table_gen.FuseTable.from_csv(csv) 44 t.verify() 45 46 self.assertEqual(t[0].field_name, 'name1') 47 self.assertEqual(t[0].efuse_block, 'EFUSE_BLK3') 48 self.assertEqual(t[0].bit_start, 0) 49 self.assertEqual(t[0].bit_count, 5) 50 self.assertEqual(t[0].comment, 'Use for test name 1') 51 52 self.assertEqual(t[1].field_name, 'name2') 53 self.assertEqual(t[1].efuse_block, 'EFUSE_BLK3') 54 self.assertEqual(t[1].bit_start, 5) 55 self.assertEqual(t[1].bit_count, 4) 56 self.assertEqual(t[1].comment, 'Use for test name 2') 57 58 def test_seq_bit_start1_fill(self): 59 csv = """ 60# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 61name1, EFUSE_BLK3, , 5, 62name2, EFUSE_BLK3, , 4, 63""" 64 t = efuse_table_gen.FuseTable.from_csv(csv) 65 t.verify() 66 67 self.assertEqual(t[0].field_name, 'name1') 68 self.assertEqual(t[0].bit_start, 0) 69 self.assertEqual(t[0].bit_count, 5) 70 71 self.assertEqual(t[1].field_name, 'name2') 72 self.assertEqual(t[1].bit_start, 5) 73 self.assertEqual(t[1].bit_count, 4) 74 75 def test_seq_bit_start2_fill(self): 76 csv = """ 77# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 78name1, EFUSE_BLK3, , 5, 79name2, EFUSE_BLK2, , 4, 80""" 81 t = efuse_table_gen.FuseTable.from_csv(csv) 82 t.verify() 83 84 self.assertEqual(t[0].field_name, 'name1') 85 self.assertEqual(t[0].bit_start, 0) 86 self.assertEqual(t[0].bit_count, 5) 87 88 self.assertEqual(t[1].field_name, 'name2') 89 self.assertEqual(t[1].bit_start, 0) 90 self.assertEqual(t[1].bit_count, 4) 91 92 def test_seq_bit_start3_fill(self): 93 csv = """ 94# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 95name1, EFUSE_BLK3, , 5, 96name2, EFUSE_BLK2, , 4, 97 98name3, EFUSE_BLK2, 5, 4, 99""" 100 t = efuse_table_gen.FuseTable.from_csv(csv) 101 t.verify() 102 103 self.assertEqual(t[0].field_name, 'name1') 104 self.assertEqual(t[0].bit_start, 0) 105 self.assertEqual(t[0].bit_count, 5) 106 107 self.assertEqual(t[1].field_name, 'name2') 108 self.assertEqual(t[1].bit_start, 0) 109 self.assertEqual(t[1].bit_count, 4) 110 111 self.assertEqual(t[2].field_name, 'name3') 112 self.assertEqual(t[2].bit_start, 5) 113 self.assertEqual(t[2].bit_count, 4) 114 115 def test_seq_bit_start4_fill(self): 116 csv = """ 117# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 118name1, EFUSE_BLK3, , 5, 119name2, EFUSE_BLK2, , 4, 120, EFUSE_BLK2, , 4, 121name1, EFUSE_BLK3, , 5, 122""" 123 with self.assertRaisesRegex(efuse_table_gen.InputError, 'Field names must be unique'): 124 efuse_table_gen.FuseTable.from_csv(csv) 125 126 def test_seq_bit_start5_fill(self): 127 csv = """ 128# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 129name1, EFUSE_BLK3, , 5, 130name2, EFUSE_BLK2, , 4, 131, EFUSE_BLK2, , 4, 132name3, EFUSE_BLK3, 5, 5, 133""" 134 t = efuse_table_gen.FuseTable.from_csv(csv) 135 t.verify() 136 137 self.assertEqual(t[0].field_name, 'name1') 138 self.assertEqual(t[0].bit_start, 0) 139 self.assertEqual(t[0].bit_count, 5) 140 141 self.assertEqual(t[1].field_name, 'name2') 142 self.assertEqual(t[1].bit_start, 0) 143 self.assertEqual(t[1].bit_count, 4) 144 145 self.assertEqual(t[2].field_name, 'name2') 146 self.assertEqual(t[2].bit_start, 4) 147 self.assertEqual(t[2].bit_count, 4) 148 149 self.assertEqual(t[3].field_name, 'name3') 150 self.assertEqual(t[3].bit_start, 5) 151 self.assertEqual(t[3].bit_count, 5) 152 153 def test_overlapping_bit_start_fail(self): 154 csv = """ 155# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 156name1, EFUSE_BLK3, 1, 5, Use for test name 1 157name2, EFUSE_BLK3, 5, 4, Use for test name 2 158 """ 159 t = efuse_table_gen.FuseTable.from_csv(csv) 160 with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'): 161 t.verify() 162 163 def test_empty_field_name_fail(self): 164 csv = """ 165# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 166, EFUSE_BLK3, , 5, 167name2, EFUSE_BLK2, , 4, 168""" 169 with self.assertRaisesRegex(efuse_table_gen.InputError, 'missing field name'): 170 efuse_table_gen.FuseTable.from_csv(csv) 171 172 def test_unique_field_name_fail(self): 173 csv = """ 174# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 175name1, EFUSE_BLK3, 0, 5, Use for test name 1 176name1, EFUSE_BLK3, 5, 4, Use for test name 2 177 """ 178 with self.assertRaisesRegex(efuse_table_gen.InputError, 'Field names must be unique'): 179 efuse_table_gen.FuseTable.from_csv(csv) 180 181 def test_bit_count_empty_fail(self): 182 csv = """ 183# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 184name1, EFUSE_BLK3, 0, , Use for test name 1 185name2, EFUSE_BLK3, 5, 4, Use for test name 2 186 """ 187 with self.assertRaisesRegex(efuse_table_gen.InputError, 'empty'): 188 efuse_table_gen.FuseTable.from_csv(csv) 189 190 def test_bit_start_num_fail(self): 191 csv = """ 192# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 193name1, EFUSE_BLK3, k, 5, Use for test name 1 194name2, EFUSE_BLK3, 5, 4, Use for test name 2 195 """ 196 with self.assertRaisesRegex(efuse_table_gen.InputError, 'Invalid field value'): 197 efuse_table_gen.FuseTable.from_csv(csv) 198 199 def test_join_entry(self): 200 csv = """ 201# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 202name1, EFUSE_BLK2, 0, 6, Use for test name 1 203name2, EFUSE_BLK2, 6, 5, Use for test name 2 204name3, EFUSE_BLK3, 20, 5, Use for test name 3 205, EFUSE_BLK3, 30, 5, Use for test name 3 206name4, EFUSE_BLK2, 30, 5, Use for test name 4 207 """ 208 t = efuse_table_gen.FuseTable.from_csv(csv) 209 t.verify() 210 211 self.assertEqual(t[0].field_name, 'name1') 212 self.assertEqual(t[0].efuse_block, 'EFUSE_BLK2') 213 self.assertEqual(t[0].bit_start, 0) 214 self.assertEqual(t[0].bit_count, 6) 215 216 self.assertEqual(t[1].field_name, 'name2') 217 self.assertEqual(t[1].efuse_block, 'EFUSE_BLK2') 218 self.assertEqual(t[1].bit_start, 6) 219 self.assertEqual(t[1].bit_count, 5) 220 221 self.assertEqual(t[2].field_name, 'name3') 222 self.assertEqual(t[2].efuse_block, 'EFUSE_BLK3') 223 self.assertEqual(t[2].bit_start, 20) 224 self.assertEqual(t[2].bit_count, 5) 225 226 self.assertEqual(t[3].field_name, 'name3') 227 self.assertEqual(t[3].efuse_block, 'EFUSE_BLK3') 228 self.assertEqual(t[3].bit_start, 30) 229 self.assertEqual(t[3].bit_count, 5) 230 231 self.assertEqual(t[4].field_name, 'name4') 232 self.assertEqual(t[4].efuse_block, 'EFUSE_BLK2') 233 self.assertEqual(t[4].bit_start, 30) 234 self.assertEqual(t[4].bit_count, 5) 235 236 def test_block_fail(self): 237 csv = """ 238# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 239name1, EFUSE_BLK5, 0, 5, Use for test name 1 240name2, EFUSE_BLK3, 5, 4, Use for test name 2 241 """ 242 with self.assertRaisesRegex(efuse_table_gen.InputError, "'efuse_block' should be one of EFUSE_BLK0..EFUSE_BLK3"): 243 efuse_table_gen.FuseTable.from_csv(csv) 244 245 def test_field_size_is_ok(self): 246 csv = """ 247# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 248name1, EFUSE_BLK0, 0, 224, Use for test name 1 249name2, EFUSE_BLK1, 0, 256, Use for test name 2 250 """ 251 efuse_table_gen.max_blk_len = 256 252 t = efuse_table_gen.FuseTable.from_csv(csv) 253 t.verify() 254 255 def test_field_blk3_size_is_more(self): 256 csv = """ 257# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 258name1, EFUSE_BLK3, 190, 1, Use for test name 1 259name2, EFUSE_BLK3, 191, 5, Use for test name 2 260 """ 261 efuse_table_gen.max_blk_len = 192 262 t = efuse_table_gen.FuseTable.from_csv(csv) 263 with self.assertRaisesRegex(efuse_table_gen.InputError, 'The field is outside the boundaries'): 264 t.verify() 265 266 def test_field_blk1_size_is_more(self): 267 csv = """ 268# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 269name1, EFUSE_BLK0, 0, 224, Use for test name 1 270name2, EFUSE_BLK1, 1, 256, Use for test name 2 271 """ 272 t = efuse_table_gen.FuseTable.from_csv(csv) 273 with self.assertRaisesRegex(efuse_table_gen.InputError, 'The field is outside the boundaries'): 274 t.verify() 275 276 277class VerificationTests(Py23TestCase): 278 279 def test_general(self): 280 csv = """ 281# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 282name1, EFUSE_BLK3, 0, 5, Use for test name 1 283name2, EFUSE_BLK3, 5, 4, Use for test name 2 284name1_1, EFUSE_BLK2, 0, 5, Use for test name 1_1 285name2_1, EFUSE_BLK2, 5, 4, Use for test name 2_1 286 """ 287 t = efuse_table_gen.FuseTable.from_csv(csv) 288 t.verify() 289 290 self.assertEqual(t[0].field_name, 'name1') 291 self.assertEqual(t[0].efuse_block, 'EFUSE_BLK3') 292 self.assertEqual(t[0].bit_start, 0) 293 self.assertEqual(t[0].bit_count, 5) 294 295 self.assertEqual(t[1].field_name, 'name2') 296 self.assertEqual(t[1].efuse_block, 'EFUSE_BLK3') 297 self.assertEqual(t[1].bit_start, 5) 298 self.assertEqual(t[1].bit_count, 4) 299 300 self.assertEqual(t[2].field_name, 'name1_1') 301 self.assertEqual(t[2].efuse_block, 'EFUSE_BLK2') 302 self.assertEqual(t[2].bit_start, 0) 303 self.assertEqual(t[2].bit_count, 5) 304 305 self.assertEqual(t[3].field_name, 'name2_1') 306 self.assertEqual(t[3].efuse_block, 'EFUSE_BLK2') 307 self.assertEqual(t[3].bit_start, 5) 308 self.assertEqual(t[3].bit_count, 4) 309 310 def test_common_and_custom_table_use_the_same_bits(self): 311 csv_common = """ 312# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 313name1, EFUSE_BLK3, 0, 5, Use for test name 1 314name2, EFUSE_BLK2, 5, 4, Use for test name 2 315 """ 316 common_table = efuse_table_gen.FuseTable.from_csv(csv_common) 317 common_table.verify('common_table') 318 two_tables = common_table 319 320 csv_custom = """ 321# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 322name3, EFUSE_BLK3, 20, 5, Use for test name 1 323name4, EFUSE_BLK3, 4, 1, Use for test name 2 324 """ 325 custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom) 326 custom_table.verify('custom_table') 327 328 two_tables += custom_table 329 with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'): 330 two_tables.verify() 331 332 def test_common_and_custom_table_use_nested_fields(self): 333 csv_common = """ 334# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 335namet1, EFUSE_BLK3, 0, 5, comment 336namet2, EFUSE_BLK1, 8, 4, comment 337 """ 338 common_table = efuse_table_gen.FuseTable.from_csv(csv_common) 339 common_table.verify('common_table') 340 two_tables = common_table 341 342 csv_custom = """ 343# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 344namet1.D1, EFUSE_BLK3, 0, 2, comment 345namet1.D1.D11, EFUSE_BLK3, 0, 1, comment 346namet1.D1.D12, EFUSE_BLK3, 1, 1, comment 347namet1.D2, EFUSE_BLK3, 2, 3, comment 348namet2.F1, EFUSE_BLK1, 9, 1, comment 349 """ 350 custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom) 351 custom_table.verify('custom_table') 352 353 two_tables += custom_table 354 two_tables.verify() 355 356 def test_common_and_custom_table_use_nested_fields2(self): 357 csv_common = """ 358# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 359namet3, EFUSE_BLK3, 0, 5, comment 360namet2, EFUSE_BLK1, 8, 4, comment 361 """ 362 common_table = efuse_table_gen.FuseTable.from_csv(csv_common) 363 common_table.verify('common_table') 364 two_tables = common_table 365 366 csv_custom = """ 367# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 368namet1.D1, EFUSE_BLK3, 0, 2, comment 369namet1.D1.D11, EFUSE_BLK3, 0, 1, comment 370namet1.D1.D12, EFUSE_BLK3, 1, 1, comment 371namet1.D2, EFUSE_BLK3, 2, 3, comment 372namet2.F1, EFUSE_BLK1, 9, 1, comment 373 """ 374 custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom) 375 custom_table.verify('custom_table') 376 377 two_tables += custom_table 378 with self.assertRaisesRegex(efuse_table_gen.InputError, 'namet1 is not found'): 379 two_tables.verify() 380 381 def test_nested_fields1(self): 382 csv = """ 383# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 384name1, EFUSE_BLK3, 0, 5, comment 385name1.D1, EFUSE_BLK3, 0, 4, comment 386name1.D1.D2, EFUSE_BLK3, 0, 3, comment 387name1.D1.D2.D3, EFUSE_BLK3, 0, 2, comment 388name1.D1.D2.D3.D4, EFUSE_BLK3, 0, 1, comment 389 """ 390 t = efuse_table_gen.FuseTable.from_csv(csv) 391 t.verify() 392 393 for i in range(0, 5): 394 self.assertEqual(t[i].bit_start, 0) 395 self.assertEqual(t[i].bit_count, 5 - i) 396 397 def test_nested_fields2(self): 398 csv = """ 399# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 400name1, EFUSE_BLK3, 0, 5, comment 401name1.D1, EFUSE_BLK3, 1, 4, comment 402name1.D1.D2, EFUSE_BLK3, 2, 3, comment 403name1.D1.D2.D3, EFUSE_BLK3, 3, 2, comment 404name1.D1.D2.D3.D4, EFUSE_BLK3, 4, 1, comment 405 """ 406 t = efuse_table_gen.FuseTable.from_csv(csv) 407 t.verify() 408 409 for i in range(0, 5): 410 self.assertEqual(t[i].bit_start, i) 411 self.assertEqual(t[i].bit_count, 5 - i) 412 413 def test_nested_fields_fail1(self): 414 csv = """ 415# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 416name1, EFUSE_BLK3, 0, 5, comment 417name1.D1, EFUSE_BLK3, 1, 4, comment 418name1.D1.D2, EFUSE_BLK3, 0, 1, comment 419 """ 420 t = efuse_table_gen.FuseTable.from_csv(csv) 421 with self.assertRaisesRegex(efuse_table_gen.InputError, 'out of range'): 422 t.verify() 423 424 def test_nested_fields_fail2(self): 425 csv = """ 426# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 427name1, EFUSE_BLK3, 0, 5, comment 428namet2, EFUSE_BLK2, 8, 4, comment 429namet2.F1, EFUSE_BLK2, 5, 4, comment 430 """ 431 t = efuse_table_gen.FuseTable.from_csv(csv) 432 with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'): 433 t.verify() 434 435 def test_nested_fields_fail3(self): 436 csv = """ 437# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 438name1, EFUSE_BLK3, 10, 5, comment 439name11, EFUSE_BLK3, 5, 1, comment 440namet2.F1, EFUSE_BLK2, 22, 1, comment 441 """ 442 t = efuse_table_gen.FuseTable.from_csv(csv) 443 with self.assertRaisesRegex(efuse_table_gen.InputError, 'namet2 is not found'): 444 t.verify() 445 446 def test_nested_fields_fail4(self): 447 csv = """ 448# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment 449name1, EFUSE_BLK3, 10, 5, comment 450name2, EFUSE_BLK3, 5, 1, comment 451name2.F1, EFUSE_BLK2, 22, 1, comment 452 """ 453 t = efuse_table_gen.FuseTable.from_csv(csv) 454 with self.assertRaisesRegex(efuse_table_gen.InputError, 'name2 is not found'): 455 t.verify() 456 457 def test_two_fields_with_lists(self): 458 csv = """ 459MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0] 460, EFUSE_BLK1, 32, 8, Factory MAC addr [1] 461, EFUSE_BLK1, 24, 8, Factory MAC addr [2] 462, EFUSE_BLK1, 16, 8, Factory MAC addr [3] 463, EFUSE_BLK1, 8, 8, Factory MAC addr [4] 464, EFUSE_BLK1, 0, 8, Factory MAC addr [5] 465MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0] 466, EFUSE_BLK1, 131, 8, Extend MAC addr [1] 467 """ 468 t = efuse_table_gen.FuseTable.from_csv(csv) 469 t.verify() 470 471 self.assertEqual(t[0].field_name, 'MAC_FACTORY') 472 self.assertEqual(t[0].group, str(0)) 473 self.assertEqual(t[1].field_name, 'MAC_FACTORY') 474 self.assertEqual(t[1].group, str(1)) 475 self.assertEqual(t[2].field_name, 'MAC_FACTORY') 476 self.assertEqual(t[2].group, str(2)) 477 self.assertEqual(t[3].field_name, 'MAC_FACTORY') 478 self.assertEqual(t[3].group, str(3)) 479 self.assertEqual(t[4].field_name, 'MAC_FACTORY') 480 self.assertEqual(t[4].group, str(4)) 481 self.assertEqual(t[5].field_name, 'MAC_FACTORY') 482 self.assertEqual(t[5].group, str(5)) 483 484 self.assertEqual(t[6].field_name, 'MAC_EXT') 485 self.assertEqual(t[6].group, str(0)) 486 self.assertEqual(t[7].field_name, 'MAC_EXT') 487 self.assertEqual(t[7].group, str(1)) 488 489 def test_two_fields_with_lists_and_field_between(self): 490 csv = """ 491MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0] 492, EFUSE_BLK1, 32, 8, Factory MAC addr [1] 493, EFUSE_BLK1, 24, 8, Factory MAC addr [2] 494, EFUSE_BLK1, 16, 8, Factory MAC addr [3] 495, EFUSE_BLK1, 8, 8, Factory MAC addr [4] 496, EFUSE_BLK1, 0, 8, Factory MAC addr [5] 497name2, EFUSE_BLK3, 5, 1, comment 498MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0] 499, EFUSE_BLK1, 131, 8, Extend MAC addr [1] 500 """ 501 t = efuse_table_gen.FuseTable.from_csv(csv) 502 t.verify() 503 504 self.assertEqual(t[0].field_name, 'MAC_FACTORY') 505 self.assertEqual(t[0].group, str(0)) 506 self.assertEqual(t[1].field_name, 'MAC_FACTORY') 507 self.assertEqual(t[1].group, str(1)) 508 self.assertEqual(t[2].field_name, 'MAC_FACTORY') 509 self.assertEqual(t[2].group, str(2)) 510 self.assertEqual(t[3].field_name, 'MAC_FACTORY') 511 self.assertEqual(t[3].group, str(3)) 512 self.assertEqual(t[4].field_name, 'MAC_FACTORY') 513 self.assertEqual(t[4].group, str(4)) 514 self.assertEqual(t[5].field_name, 'MAC_FACTORY') 515 self.assertEqual(t[5].group, str(5)) 516 517 self.assertEqual(t[6].field_name, 'name2') 518 519 self.assertEqual(t[7].field_name, 'MAC_EXT') 520 self.assertEqual(t[7].group, str(0)) 521 self.assertEqual(t[8].field_name, 'MAC_EXT') 522 self.assertEqual(t[8].group, str(1)) 523 524 525if __name__ == '__main__': 526 unittest.main() 527