2016-03-22 11:09:54 |
Wenzhi Yu |
description |
Logic of nova-cells test case 'nova.tests.cells.test_cells_scheduler.test_filter_schedule_skipping' is really odd:
def test_filter_schedule_skipping(self):
# if a filter handles scheduling, short circuit
def _grab(filter_properties):
return None
self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
def _test(self, *args):
raise test.TestingException("shouldn't be called")
try:
self.scheduler._schedule_build_to_cells(None, None, None, _test,
None)
except test.TestingException:
self.fail("Scheduling did not properly short circuit")
It uses a try-except block to ensure that '_test()' function will not be called during case execution,
which is odd and poorly readable. |
Logic of nova-cells test case 'nova.tests.cells.test_cells_scheduler.test_filter_schedule_skipping' is really odd:
def test_filter_schedule_skipping(self):
# if a filter handles scheduling, short circuit
def _grab(filter_properties):
return None
self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
def _test(self, *args):
raise test.TestingException("shouldn't be called")
try:
self.scheduler._schedule_build_to_cells(None, None, None, _test,
None)
except test.TestingException:
self.fail("Scheduling did not properly short circuit")
It uses a try-except block to ensure that '_test()' function will not be called during case execution, which is odd and poorly readable. |
|
2016-03-22 11:15:27 |
Wenzhi Yu |
description |
Logic of nova-cells test case 'nova.tests.cells.test_cells_scheduler.test_filter_schedule_skipping' is really odd:
def test_filter_schedule_skipping(self):
# if a filter handles scheduling, short circuit
def _grab(filter_properties):
return None
self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
def _test(self, *args):
raise test.TestingException("shouldn't be called")
try:
self.scheduler._schedule_build_to_cells(None, None, None, _test,
None)
except test.TestingException:
self.fail("Scheduling did not properly short circuit")
It uses a try-except block to ensure that '_test()' function will not be called during case execution, which is odd and poorly readable. |
Logic of nova-cells test case 'nova.tests.unit.cells.test_cells_scheduler.test_filter_schedule_skipping'[1] is really odd:
def test_filter_schedule_skipping(self):
# if a filter handles scheduling, short circuit
def _grab(filter_properties):
return None
self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
def _test(self, *args):
raise test.TestingException("shouldn't be called")
try:
self.scheduler._schedule_build_to_cells(None, None, None, _test,
None)
except test.TestingException:
self.fail("Scheduling did not properly short circuit")
It uses a try-except block to ensure that '_test()' function will not be called during case execution, which is odd and poorly readable.
[1]https://github.com/openstack/nova/blob/13.0.0.0rc1/nova/tests/unit/cells/test_cells_scheduler.py#L354-L369 |
|