def test_load_supercars_nojson(): temp = tempfile.NamedTemporaryFile() try: temp.write('no json content') temp.seek(0) load_supercars(temp.name) finally: temp.close()
def test_load_supercars(): temp = tempfile.NamedTemporaryFile() try: temp.write('[{"json": "true"}]') temp.seek(0) result = load_supercars(temp.name) assert_equal(result, {0: {'json': 'true'}}) finally: temp.close()
def test_load_supercars_nosuchfile(): load_supercars('nosuchfile.txt')