source: sasview/sansmodels/test/utest_state.py @ 077207b

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 077207b was 18e250c, checked in by Gervaise Alina <gervyh@…>, 13 years ago

move test to sansmodels top level

  • Property mode set to 100644
File size: 895 bytes
Line 
1#!/usr/bin/env python
2"""
3    Test for setstate and reduce_ex operations for models
4"""
5import unittest
6
7from sans.models.SphereModel import SphereModel
8
9class TestSphere(unittest.TestCase):
10    def setUp(self):
11        self.sphere = SphereModel()
12       
13    def test_state_IO(self):
14        """
15            Check that a state oject is independent from the model object it
16            was generated with
17        """
18        self.sphere.setParam('radius', 44.0)
19        _, _, state, _, _ = self.sphere.__reduce_ex__(0)
20       
21        sphere_copy = SphereModel()
22        sphere_copy.__setstate__(state)
23        sphere_clone = sphere_copy.clone()
24        self.assertEqual(sphere_copy.getParam('radius'), 44)
25       
26        self.sphere.setParam('radius', 33.0)
27       
28        self.assertEqual(sphere_clone.getParam('radius'), 44)
29       
30   
31if __name__ == '__main__':
32    unittest.main()
Note: See TracBrowser for help on using the repository browser.