Esempio n. 1
0
 def test_update(self):
     """
     Tests update method of Stats object.
     """
     x = Stats({'a': 5})
     self.assertTrue('a' in dir(x))
     x.update({'b': 5})
     self.assertTrue('b' in dir(x))
     y = {'a': 5}
     y.update({'b': 5})
     x = Stats(y)
     self.assertTrue('b' in dir(x))
Esempio n. 2
0
 def test_update(self):
     """
     Tests update method of Stats object.
     """
     x = Stats({'a': 5})
     self.assertTrue('a' in dir(x))
     x.update({'b': 5})
     self.assertTrue('b' in dir(x))
     y = {'a': 5}
     y.update({'b': 5})
     x = Stats(y)
     self.assertTrue('b' in dir(x))
Esempio n. 3
0
 def test_update(self):
     """
     Tests update method of Stats object.
     """
     x = Stats({"a": 5})
     self.assertTrue("a" in dir(x))
     x.update({"b": 5})
     self.assertTrue("b" in dir(x))
     y = {"a": 5}
     y.update({"b": 5})
     x = Stats(y)
     self.assertTrue("b" in dir(x))
Esempio n. 4
0
 def test_update(self):
     """
     Tests update method of Stats object.
     """
     x = Stats({'a': 5})
     assert 'a' in dir(x)
     x.update({'b': 5})
     assert 'b' in dir(x)
     y = {'a': 5}
     y.update({'b': 5})
     x = Stats(y)
     assert 'b' in dir(x)
Esempio n. 5
0
 def test_setCalib(self):
     """
     Test to prevent setting a calibration factor of 0
     """
     x = Stats()
     # this should work
     x.update({'calib': 1.23})
     self.assertTrue(x.calib, 1.23)
     # this raises UserWarning
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('error', UserWarning)
         # 1
         self.assertRaises(UserWarning, x.__setitem__, 'calib', 0)
         # 2
         self.assertRaises(UserWarning, x.update, {'calib': 0})
     # calib value should nevertheless be set to 0
     self.assertTrue(x.calib, 0)
Esempio n. 6
0
 def test_setCalib(self):
     """
     Test to prevent setting a calibration factor of 0
     """
     x = Stats()
     # this should work
     x.update({'calib': 1.23})
     self.assertTrue(x.calib, 1.23)
     # this raises UserWarning
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('error', UserWarning)
         # 1
         self.assertRaises(UserWarning, x.__setitem__, 'calib', 0)
         # 2
         self.assertRaises(UserWarning, x.update, {'calib': 0})
     # calib value should nevertheless be set to 0
     self.assertTrue(x.calib, 0)
Esempio n. 7
0
 def test_set_calib(self):
     """
     Test to prevent setting a calibration factor of 0
     """
     x = Stats()
     # this should work
     x.update({'calib': 1.23})
     assert x.calib, 1.23
     # this raises UserWarning
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('error', UserWarning)
         # 1
         with pytest.raises(UserWarning):
             x.__setitem__('calib', 0)
         # 2
         with pytest.raises(UserWarning):
             x.update({'calib': 0})
     # calib value should nevertheless be set to 0
     assert x.calib, 0