예제 #1
0
 def test_mul_with_float(self):
     t = Temp(100, unit='C')
     t2 = t * 2
     self.assertEqual(int(t2), 200)
     self.assertEqual(t2.c, 200)
     self.assertEqual(t2.f, 392)
     self.assertEqual(t2.k, 473.15)
     self.assertIsInstance(t2, Temp)
예제 #2
0
 def test_truediv_with_float(self):
     t = Temp(573, unit='K')
     t2 = t / 2
     self.assertEqual(t2.k, 286.5)
     self.assertEqual(round(t2.c, 2), 13.35)
     self.assertEqual(round(t2.f, 2), 56.03)
     self.assertEqual(t2.k, 286.5)
     self.assertIsInstance(t2, Temp)
예제 #3
0
 def test_add_with_float(self):
     t = Temp(243.15, unit='K')
     t2 = 40 + t
     self.assertEqual(float(t2), 283.15)
     self.assertEqual(t2.c, 10)
     self.assertEqual(t2.f, 50)
     self.assertEqual(t2.k, 283.15)
     self.assertIsInstance(t2, Temp)
예제 #4
0
 def test_sub_with_float(self):
     t = Temp(68, unit='F')
     t2 = t - 36
     self.assertEqual(int(t2), 32)
     self.assertEqual(t2.c, 0)
     self.assertEqual(t2.f, 32)
     self.assertEqual(t2.k, 273.15)
     self.assertIsInstance(t2, Temp)
예제 #5
0
 def test_neg_with_float(self):
     t = Temp(-22, unit='F')
     t2 = -t
     self.assertEqual(int(t2), 22)
     self.assertEqual(round(t2.c, 2), -5.56)
     self.assertEqual(t2.f, 22)
     self.assertEqual(round(t2.k, 2), 267.59)
     self.assertIsInstance(t2, Temp)
예제 #6
0
 def test_input_temp_class(self):
     hi = heat_index(Temp(30, unit='c'), 70)
     self.assertIsInstance(hi, Temp)
     self.assertEqual(round(hi.c), 35)
     self.assertEqual(round(hi, 1), 95.1)
예제 #7
0
 def test_kelvin_to_fahrenheit(self):
     for t in temperature_values:
         temp = Temp(t['k'], unit='K')
         self.assertEqual(round(temp.f, 2), t['f'])
예제 #8
0
 def test_kelvin_to_celsius(self):
     for t in temperature_values:
         temp = Temp(t['k'], unit='K')
         self.assertEqual(round(temp.c, 2), t['c'])
예제 #9
0
 def test_fahrenheit_to_celsius(self):
     for t in temperature_values:
         temp = Temp(t['f'], unit='F')
         self.assertEqual(round(temp.c, 2), t['c'])
예제 #10
0
 def test_kelvin_to_kelvin(self):
     for t in temperature_values:
         temp = Temp(t['k'], unit='K')
         self.assertEqual(temp.k, t['k'])
예제 #11
0
 def test_fahrenheit_to_fahrenheit(self):
     for t in temperature_values:
         temp = Temp(t['f'], unit='F')
         self.assertEqual(temp.f, t['f'])
예제 #12
0
 def test_celsius_to_celsius(self):
     for t in temperature_values:
         temp = Temp(t['c'], unit='C')
         self.assertEqual(temp.c, t['c'])
예제 #13
0
 def test_input_temp_class(self):
     wc = wind_chill(Temp(-15, unit='c'), 10)
     self.assertIsInstance(wc, Temp)
     self.assertEqual(round(wc.c), -23)
예제 #14
0
 def test_input_temp_class(self):
     wc = feels_like(Temp(-15, unit='c'), 50, 10)
     self.assertIsInstance(wc, Temp)
     self.assertEqual(round(wc.c), -23)