unit test contextmanager: trying to delete resource hides original errors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Low
|
Akihiro Motoki |
Bug Description
In unit tests, resource contextmanagers such as network(), subnet() try to delete themselves after returning from yield even if an exception occurs. However when an exception occurs, there is a case where deletion fails. In this case original exception will be hidden and it makes difficult to debug test failures.
Before each time starts, resources like database entries will be recreated, so there is no need to try to delete resources even when an exception occurs.
For example, there is a test with programming error below:
def test_create_
with self.network() as network:
port = self.deserializ
# --> Some programming error!!!!
When running this unit tests, we will get the following error. It is hard to understand.
Traceback (most recent call last):
File "neutron/
self.
File "/usr/lib/
self.
File "neutron/
self.
File "neutron/
self.
File "/home/
self.
File "/home/
raise mismatch_error
MismatchError: 409 != 204
It is better we have the original exception:
Traceback (most recent call last):
File "neutron/
self.
NameError: global name 'hoge' is not defined
Changed in neutron: | |
milestone: | none → icehouse-rc1 |
Changed in neutron: | |
status: | Fix Committed → Fix Released |
Changed in neutron: | |
milestone: | icehouse-rc1 → 2014.1 |
Fix proposed to branch: master /review. openstack. org/82259
Review: https:/