comparison py/test.py @ 230:185621f47040

run 2to3
author Matt Johnston <matt@ucc.asn.au>
date Fri, 10 Apr 2015 23:59:16 +0800
parents b32e5a11a4cb
children 74c3ae4e3307
comparison
equal deleted inserted replaced
229:99255c501e02 230:185621f47040
1 #!/usr/bin/env python2.7 1 #!/usr/bin/env python2.7
2 import StringIO 2 import io
3 3
4 import unittest 4 import unittest
5 import sensor_ds18b20 5 import sensor_ds18b20
6 import params 6 import params
7 7
48 # setting a bad parameter fails 48 # setting a bad parameter fails
49 with self.assertRaises(KeyError): 49 with self.assertRaises(KeyError):
50 self.params.somewrongthing = 5 50 self.params.somewrongthing = 5
51 51
52 def test_params_load(self): 52 def test_params_load(self):
53 jsbuf = StringIO.StringIO('{"fridge_setpoint": 999}') 53 jsbuf = io.StringIO('{"fridge_setpoint": 999}')
54 54
55 self.params.load(f=jsbuf) 55 self.params.load(f=jsbuf)
56 self.assertEqual(self.params.fridge_setpoint, 999) 56 self.assertEqual(self.params.fridge_setpoint, 999)
57 57
58 with self.assertRaises(params.Params.Error): 58 with self.assertRaises(params.Params.Error):
59 jsbuf = StringIO.StringIO('{"something_else": 999}') 59 jsbuf = io.StringIO('{"something_else": 999}')
60 self.params.load(f=jsbuf) 60 self.params.load(f=jsbuf)
61 61
62 with self.assertRaises(KeyError): 62 with self.assertRaises(KeyError):
63 x = self.params.something_else 63 x = self.params.something_else
64 64
65 def test_params_save(self): 65 def test_params_save(self):
66 jsbuf = StringIO.StringIO() 66 jsbuf = io.StringIO()
67 67
68 self.params.overshoot_delay = 123 68 self.params.overshoot_delay = 123
69 self.params.save(f=jsbuf) 69 self.params.save(f=jsbuf)
70 70
71 s = jsbuf.getvalue() 71 s = jsbuf.getvalue()