| 335 | fp.close() |
| 336 | |
| 337 | def test_del_attr_handling(): |
| 338 | # DataSource __del__ can be called |
| 339 | # even if __init__ fails when the |
| 340 | # Exception object is caught by the |
| 341 | # caller as happens in refguide_check |
| 342 | # is_deprecated() function |
| 343 | |
| 344 | ds = datasource.DataSource() |
| 345 | # simulate failed __init__ by removing key attribute |
| 346 | # produced within __init__ and expected by __del__ |
| 347 | del ds._istmpdest |
| 348 | # should not raise an AttributeError if __del__ |
| 349 | # gracefully handles failed __init__: |
| 350 | ds.__del__() |