Пример #1
0
import json
from utils import metric2imperial
from classes import Film

if __name__ == "__main__":
    film = Film(1)

    film.get_all_cross_refs()
    for char in film.characters:
        char["mass"] = metric2imperial(char["mass"], "kg", "lb")
        char["height"] = metric2imperial(char["height"], "cm", "ft")
    with open("task_two.json", "w") as f:
        f.write(json.dumps(film.write_contents(), indent=2))
Пример #2
0
 def test_cm2ft(self):
     self.assertEqual(metric2imperial(100, "cm", "ft"), 3.28)
Пример #3
0
 def test_kg2lb(self):
     self.assertEqual(metric2imperial(100, "kg", "lb"), 220.5)
Пример #4
0
 def test_failure(self):
     with self.assertRaises(KeyError):
         metric2imperial(100, "in", "ft")
Пример #5
0
 def test_invalid(self):
     self.assertEqual(metric2imperial("unknown", "cm", "ft"), "unknown")
Пример #6
0
 def test_cm2ft(self):
     self.assertEqual(metric2imperial(178, "cm", "ft"), 5.84)