예제 #1
0
 def testConvertKelvinToCelcius(self):
     print "\nNow testing convertKelvinToCelcius function:"
     for i in range(0,len(self.knownValues)):
         result = conversions.convertKelvinToCelcius(self.knownValues[i][1]) # result of the conversion from kelvin to celcius
         celcius = self.knownValues[i][0]
         self.assertEqual(celcius, result) # comparing if the values are equal
         print "   testing kelvin = %f; %f = %f; Passed" % (self.knownValues[i][1], celcius, result)
예제 #2
0
def convert(fromUnit, toUnit, value):
    """Convert fromUnit value to toUnit."""

    if fromUnit == 'Fahrenheit':
        if toUnit == 'Celcius':
            return float(conversions.convertFahrenheitToCelcius(value))
        elif toUnit == 'Kelvin':
            return float(conversions.convertFahrenheitToKelvin(value))
        else:
            raise ConversionError('{} cannot be converted to {}'.format(fromUnit, toUnit))

    elif fromUnit == 'Celcius':
        if toUnit == 'Fahrenheit':
            return float(conversions.convertCelciusToFahrenheit(value))
        elif toUnit == 'Kelvin':
            return float(conversions.convertCelciusToKelvin(value))
        else:
            raise ConversionError('{} cannot be converted to {}'.format(fromUnit, toUnit))

    elif fromUnit == 'Kelvin':
        if toUnit == 'Fahrenheit':
            return float(conversions.convertKelvinToFahrenheit(value))
        elif toUnit == 'Celcius':
            return float(conversions.convertKelvinToCelcius(value))

    else:
        raise ConversionNotPossible('Cannot perform conversions')
예제 #3
0
    def testConvertKelvinToCelcius(self):
        print "\nNow testing convertKelvinToCelcius function:"

        for i in range(0, len(self.knownValues)):
            result = conversions.convertKelvinToCelcius(self.knownValues[i][1])
            celcius = self.knownValues[i][0]
            self.assertEqual(celcius, result)
            print "   testing kelvin = %f; %f = %f; Passed" % (
                self.knownValues[i][1], celcius, result)
예제 #4
0
 def test_convertKelvinToCelcius(self):
     for x in self.celToKelKnown:
         # Run conversion
         result = conversions.convertKelvinToCelcius(x[1])
         # Check result
         self.assertEqual(result, x[0])
         # Print test
         print 'Testing Kelvin ' + str(x[1]) + ' converts to ' + str(
             x[0]) + ' Celcius.'
예제 #5
0
 def testFromKevintoFahrenheitPositive(self):
     print("Checks if 773.15k produces 500.00F")
     self.assertAlmostEqual(500.00,
                            conversions.convertKelvinToCelcius(773.15),
                            places=2)
예제 #6
0
 def testKToC(self):
     """should produce known result with know input"""
     for input, output in self.knownValuesK2C:
         result = conversions.convertKelvinToCelcius(input)
         self.assertEqual(output, result, msg = 'Test converting {}K to Celsius. Result {}. Expected {}'.format(input, result, output))
예제 #7
0
 def testConvertKelvinToCelcius(self):
     """convertKelvinToCelcius should give knownKelvinConversion results"""
     for celcius, kelvin in self.knownKelvinConversions:
         result = float(conversions.convertKelvinToCelcius(kelvin))
         self.assertEqual(celcius, result)
        def testKelvintoCelcius(self):

                for i in range(len(self.kel)):
                        celcius = conversions.convertKelvinToCelcius(
                                self.kel[i])
                        self.assertEqual(self.cel[i],celcius,msg='{}C != {}C'.format(celcius,self.cel[i]))
예제 #9
0
 def testconvertKelvinToCelsius(self):
     print 'Testing that convertKelvinToCelsius returns the correct known values'
     for k, c in self.k2cKnownValues:
         result = conversions.convertKelvinToCelcius(k)
         self.assertEqual(c, result)
예제 #10
0
 def testConvertKelvinToCelcius(self):
     """convertKelvinToCelcius should give known result with known input"""
     for celcius, _, kelvin in self.knownValues:
         result = conversions.convertKelvinToCelcius(kelvin)
         self.assertEqual(celcius, result)
예제 #11
0
 def testSanityCelciusAndKelvin(self):
     """convertKelvinToCelcius(convertCelciusToKelvin(n))==n for all n"""
     for integer in range(1, 4000):
         numeral = conversions.convertCelciusToKelvin(integer)
         result = conversions.convertKelvinToCelcius(numeral)
         self.assertEqual(integer, result)