Пример #1
0
    def test_bad_units(self):
        with self.assertRaises(M10SException):
            length.convert(1, 'cm', 'anakin skywalker')

        with self.assertRaises(M10SException):
            length.convert(1, 'ahsoka tano', 'km')

        with self.assertRaises(M10SException):
            length.convert_si(1, 'this is so wizard!')
Пример #2
0
 def test_convert_nm(self):
     self.assertEqual(1e-12, length.convert(1, 'nm', 'km'))
     self.assertEqual(1e-9, length.convert(1, 'nm', 'm'))
     self.assertEqual(1e-7, length.convert(1, 'nm', 'cm'))
Пример #3
0
 def test_convert_um(self):
     self.assertEqual(1e-9, length.convert(1, 'um', 'km'))
     self.assertEqual(1e-4, length.convert(1, 'um', 'cm'))
     self.assertEqual(1000, length.convert(1, 'um', 'nm'))
Пример #4
0
 def test_convert_mm(self):
     self.assertEqual(1e-6, length.convert(1, 'mm', 'km'))
     self.assertEqual(0.1, length.convert(1, 'mm', 'cm'))
     self.assertEqual(1e+6, length.convert(1, 'mm', 'nm'))
Пример #5
0
 def test_convert_cm(self):
     self.assertEqual(0.00001, length.convert(1, 'cm', 'km'))
     self.assertEqual(0.1, length.convert(1, 'cm', 'dm'))
     self.assertEqual(1e+7, length.convert(1, 'cm', 'nm'))
Пример #6
0
 def test_convert_m(self):
     self.assertEqual(0.001, length.convert(1, 'm', 'km'))
     self.assertEqual(100, length.convert(1, 'm', 'cm'))
     self.assertEqual(1e+9, length.convert(1, 'm', 'nm'))
Пример #7
0
 def test_convert_km(self):
     self.assertEqual(1000, length.convert(1, 'km', 'm'))
     self.assertEqual(100000, length.convert(1, 'km', 'cm'))
     self.assertEqual(1e+12, length.convert(1, 'km', 'nm'))