| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # | 2 # |
| 3 # Protocol Buffers - Google's data interchange format | 3 # Protocol Buffers - Google's data interchange format |
| 4 # Copyright 2008 Google Inc. All rights reserved. | 4 # Copyright 2008 Google Inc. All rights reserved. |
| 5 # https://developers.google.com/protocol-buffers/ | 5 # https://developers.google.com/protocol-buffers/ |
| 6 # | 6 # |
| 7 # Redistribution and use in source and binary forms, with or without | 7 # Redistribution and use in source and binary forms, with or without |
| 8 # modification, are permitted provided that the following conditions are | 8 # modification, are permitted provided that the following conditions are |
| 9 # met: | 9 # met: |
| 10 # | 10 # |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 class TestGeneratorMetaclass(type): | 341 class TestGeneratorMetaclass(type): |
| 342 """Metaclass for test cases with test generators. | 342 """Metaclass for test cases with test generators. |
| 343 | 343 |
| 344 A test generator is an iterable in a testcase that produces callables. These | 344 A test generator is an iterable in a testcase that produces callables. These |
| 345 callables must be single-argument methods. These methods are injected into | 345 callables must be single-argument methods. These methods are injected into |
| 346 the class namespace and the original iterable is removed. If the name of the | 346 the class namespace and the original iterable is removed. If the name of the |
| 347 iterable conforms to the test pattern, the injected methods will be picked | 347 iterable conforms to the test pattern, the injected methods will be picked |
| 348 up as tests by the unittest framework. | 348 up as tests by the unittest framework. |
| 349 | 349 |
| 350 In general, it is supposed to be used in conjuction with the | 350 In general, it is supposed to be used in conjunction with the |
| 351 Parameters decorator. | 351 Parameters decorator. |
| 352 """ | 352 """ |
| 353 | 353 |
| 354 def __new__(mcs, class_name, bases, dct): | 354 def __new__(mcs, class_name, bases, dct): |
| 355 dct['_id_suffix'] = id_suffix = {} | 355 dct['_id_suffix'] = id_suffix = {} |
| 356 for name, obj in dct.items(): | 356 for name, obj in dct.items(): |
| 357 if (name.startswith(unittest.TestLoader.testMethodPrefix) and | 357 if (name.startswith(unittest.TestLoader.testMethodPrefix) and |
| 358 _NonStringIterable(obj)): | 358 _NonStringIterable(obj)): |
| 359 iterator = iter(obj) | 359 iterator = iter(obj) |
| 360 dct.pop(name) | 360 dct.pop(name) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 Returns: | 434 Returns: |
| 435 A new class object. | 435 A new class object. |
| 436 """ | 436 """ |
| 437 metaclass = type( | 437 metaclass = type( |
| 438 'CoopMetaclass', | 438 'CoopMetaclass', |
| 439 (other_base_class.__metaclass__, | 439 (other_base_class.__metaclass__, |
| 440 TestGeneratorMetaclass), {}) | 440 TestGeneratorMetaclass), {}) |
| 441 return metaclass( | 441 return metaclass( |
| 442 'CoopParameterizedTestCase', | 442 'CoopParameterizedTestCase', |
| 443 (other_base_class, ParameterizedTestCase), {}) | 443 (other_base_class, ParameterizedTestCase), {}) |
| OLD | NEW |