def generate_methods(): confusables_table = gen_confusables_table.build_confusables_table( gen_confusables_table.get_confusables_file()) test_methods = {} for k, v in confusables_table.items(): def test_method(self): self.assertEqual(v, confusables.skeleton(chr(k))) setattr(TestConfusables, "test_confusable_{:08x}".format(k), test_method) def test_confusable_out_of_bounds(self): max_confusable_plus_one = chr(max(confusables_table.keys()) + 1) self.assertEqual(max_confusable_plus_one, confusables.skeleton(max_confusable_plus_one)) setattr(TestConfusables, "test_confusable_out_of_bounds", test_confusable_out_of_bounds)
#!/usr/bin/env python3 from setuptools import setup, Extension from setuptools.command.build_ext import build_ext import gen_confusables_table VERSION_PREFIX = "# Version: " cf = gen_confusables_table.get_confusables_file() # this delays import of Cython to a moment when it is installed class lazy_cythonize(list): def __init__(self, callback): self._list, self.callback = None, callback def c_list(self): if self._list is None: self._list = self.callback() return self._list def __iter__(self): for e in self.c_list(): yield e def __getitem__(self, ii): return self.c_list()[ii] def __len__(self): return len(self.c_list())
#!/usr/bin/env python3 from setuptools import setup, Extension from setuptools.command.build_ext import build_ext import gen_confusables_table VERSION_PREFIX = '# Version: ' cf = gen_confusables_table.get_confusables_file() # this delays import of Cython to a moment when it is installed class lazy_cythonize(list): def __init__(self, callback): self._list, self.callback = None, callback def c_list(self): if self._list is None: self._list = self.callback() return self._list def __iter__(self): for e in self.c_list(): yield e def __getitem__(self, ii): return self.c_list()[ii] def __len__(self): return len(self.c_list()) def extensions(): from Cython.Build import cythonize ext = Extension('_confusables', sources=['src/_confusables.pyx'])