def mainwin_recentfiles(): MainWindow.dict_modified = False MainWindow.max_recent_files = 2 # resetting recent files settings = QSettings('PMA', 'OneHandTextEdit') settings.setValue('recent_files', []) src = 'test_words.txt' dest = 'test_out.json' words = ["may", "cat"] with open(src, 'w') as f: for word in words: f.write("%s\n" % word) create_regex_map([src], [True], dest) with open(dest) as f: regex_map = json.load(f) yield MainWindow(regex_map, dict_src=dest) os.remove(src) os.remove(dest) os.remove('document1.txt') os.remove('document2.txt') os.remove('document3.txt') # resetting recent files settings = QSettings('PMA', 'OneHandTextEdit') settings.setValue('recent_files', [])
def test_basic(self): create_regex_map([self.src1, self.src2, self.src3], [False, True], self.dest) with open(self.dest) as f: output = f.readline() self.assertEqual( output, '{"a": {"default": "a", "words": ["a"]}, "tge": {"default": "the", "words": ["the", "thi"]}, "b": {"default": "B", "words": ["B"]}}' )
def setUp(self) -> None: self.src = 'test_words.txt' self.dest = 'test_out.json' words = ["may", "cat"] with open(self.src, 'w') as f: for word in words: f.write("%s\n" % word) create_regex_map([self.src], [True], self.dest) with open(self.dest) as f: self.regex_map = json.load(f)
def setUpClass(cls) -> None: cls.src = 'test_words.txt' cls.dest = 'test_out.json' words = ["may", "cat"] with open(cls.src, 'w') as f: for word in words: f.write("%s\n" % word) create_regex_map([cls.src], [True], cls.dest) with open(cls.dest) as f: cls.regex_map = json.load(f)
def setUpModule(): if QApplication.instance() is None: app = QApplication([]) words = [ "e", "i", "the", "and", "ax", "it's", "den", "din", "ken", "en", "in", "hex", "he", "hi", "z" ] with open(src, 'w') as f: for word in words: f.write("%s\n" % word) create_regex_map([src], [False], dest) with open(dest) as f: global regex_map regex_map = json.load(f)
def main_win(): MainWindow.dict_modified = False src = 'test_words.txt' dest = 'test_out.json' words = ["may", "cat"] with open(src, 'w') as f: for word in words: f.write("%s\n" % word) create_regex_map([src], [True], dest) with open(dest) as f: regex_map = json.load(f) yield MainWindow(regex_map, dict_src=dest) os.remove(src) os.remove(dest)