def test(self): data = Upconverter.parse(json_file_path, 'openjson') self.assertTrue(data != None) tmp_fd, tmp_path = tempfile.mkstemp() os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertTrue(get_file_contents(tmp_path) != '') os.remove(tmp_path)
def test(self): data = Upconverter.parse(json_file_path, "openjson") self.assertTrue(data != None) tmp_fd, tmp_path = tempfile.mkstemp() os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertTrue(check_output(tmp_path) != "") os.remove(tmp_path)
def test(self): data = Upconverter.parse(file_path, format) self.assertTrue(data != None) tmp_fd, tmp_path = tempfile.mkstemp() os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertTrue(check_output(tmp_path) != "") self.assertTrue(file_diff(file_path, tmp_path).ratio() > 0.95, (file_path, tmp_path)) os.remove(tmp_path)
def test(self): data = Upconverter.parse(file_path, format) self.assertTrue(data != None) if format not in ['gerber']: verify_json(data.json()) tmp_fd, tmp_path = tempfile.mkstemp() os.close(tmp_fd) Upconverter.write(data, tmp_path, 'openjson') self.assertTrue(get_file_contents(tmp_path) != '') os.remove(tmp_path)
def test(self): data = Upconverter.parse(file_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_1 = tempfile.mkstemp(prefix='test.1.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_1, 'openjson') self.assertNotEqual(get_file_contents(json_path_1), '') tmp_fd, tmp_path = tempfile.mkstemp(suffix='.' + format) os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertNotEqual(get_file_contents(tmp_path), '') data = Upconverter.parse(tmp_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_2 = tempfile.mkstemp(prefix='test.2.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_2, 'openjson') self.assertNotEqual(get_file_contents(json_path_2), '') ratio = get_file_diff_ratio(json_path_1, json_path_2) self.assertTrue(ratio <= max_diff_ratios[format], (file_path, tmp_path, json_path_1, json_path_2, ratio)) os.remove(json_path_1) os.remove(json_path_2) os.remove(tmp_path)
def test(self): try: data = Upconverter.parse(file_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_1 = tempfile.mkstemp(prefix='test.1.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_1, 'openjson') self.assertNotEqual(get_file_contents(json_path_1), '') tmp_fd, tmp_path = tempfile.mkstemp(suffix='.' + format) os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertNotEqual(get_file_contents(tmp_path), '') data = Upconverter.parse(tmp_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_2 = tempfile.mkstemp(prefix='test.2.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_2, 'openjson') self.assertNotEqual(get_file_contents(json_path_2), '') ratio = get_file_diff_ratio(json_path_1, json_path_2) self.assertTrue( ratio <= max_diff_ratios[format], (file_path, tmp_path, json_path_1, json_path_2, ratio)) finally: # need to remove each file if a failure occured. # tries handle variables that have not yet been instantiated. try: os.remove(json_path_1) except: pass try: os.remove(json_path_2) except: pass try: os.remove(splitext(tmp_path)[0] + '-cache.lib') except: pass try: os.remove(tmp_path) except: pass
def main(): imported_files = [] os.path.walk('./test/imported', filter_all, imported_files) failed_to_autodetect = [] failed_to_parse = [] for file_path in imported_files: try: # test autodetection format = Upconverter.autodetect(file_path) try: # test conversion data = Upconverter.parse(file_path, format) except Exception, e: failed_to_parse.append(file_path) print traceback.print_exc() except Exception, e: failed_to_autodetect.append(file_path) print traceback.print_exc()
def test(self): try: data = Upconverter.parse(file_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_1 = tempfile.mkstemp(prefix='test.1.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_1, 'openjson') self.assertNotEqual(get_file_contents(json_path_1), '') tmp_fd, tmp_path = tempfile.mkstemp(suffix='.' + format) os.close(tmp_fd) Upconverter.write(data, tmp_path, format) self.assertNotEqual(get_file_contents(tmp_path), '') data = Upconverter.parse(tmp_path, format) self.assertNotEqual(data, None) tmp_fd, json_path_2 = tempfile.mkstemp(prefix='test.2.', suffix='.upv') os.close(tmp_fd) Upconverter.write(data, json_path_2, 'openjson') self.assertNotEqual(get_file_contents(json_path_2), '') ratio = get_file_diff_ratio(json_path_1, json_path_2) self.assertTrue(ratio <= max_diff_ratios[format], (file_path, tmp_path, json_path_1, json_path_2, ratio)) finally: # need to remove each file if a failure occured. # tries handle variables that have not yet been instantiated. try: os.remove(json_path_1) except: pass try: os.remove(json_path_2) except: pass try: os.remove(splitext(tmp_path)[0] + '-cache.lib') except: pass try: os.remove(tmp_path) except: pass
def test(self): self.assertEqual(Upconverter.autodetect(file_path), format)