Check if a late call to __init__() modifies the C++ object
(self)
| 140 | self.assertTrue(vtkPoints().__class__ == vtkPoints) |
| 141 | |
| 142 | def testOverrideWarning(self): |
| 143 | """Check if a late call to __init__() modifies the C++ object""" |
| 144 | # check that the object has the correct class |
| 145 | vtkImageData.override(vtkImageDataWarning) |
| 146 | self.assertTrue(isinstance(vtkImageData(), vtkImageDataWarning)) |
| 147 | # check object created deep in c++ |
| 148 | source = vtkImageGridSource() |
| 149 | source.SetDataExtent(0, 255, 0, 255, 0, 0) |
| 150 | source.SetDataSpacing(0.1, 0.1, 1.0) |
| 151 | # calling Update() instantiates the data object in C++ |
| 152 | source.Update() |
| 153 | # calling GetOutput() instantiates the data object in Python, |
| 154 | # and reports RuntimeWarning because our override modifies the data |
| 155 | with self.assertWarns(RuntimeWarning): |
| 156 | data = source.GetOutput() |
| 157 | # the custom __init__() method modified the spacing to be (1.0,1.0,1.0), |
| 158 | # the purpose of the RuntimeWarning is to let the user know that an odd |
| 159 | # modification like this has occurred |
| 160 | self.assertEqual(data.GetSpacing(), (1.0, 1.0, 1.0)) |
| 161 | |
| 162 | if __name__ == "__main__": |
| 163 | Testing.main([(TestSubclass, 'test')]) |
nothing calls this directly
no test coverage detected