Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
 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)
Exemple #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'])
Exemple #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'])
Exemple #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'])
Exemple #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'])
Exemple #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'])
Exemple #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'])
Exemple #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)
 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)