def remove_words(keywords: dict, word_filename: str) -> dict: file = import_file(word_filename) removal_lst = file.split() for key in keywords.copy().keys(): if key in removal_lst: del keywords[key] return keywords
def test_unsuccessful_file_open(capsys): filename = "ats_hacker/tests/test_data/doesnt-exist.txt" try: _ = import_file(filename) except (FileNotFoundError, SystemExit): pass _, err = capsys.readouterr() want = "ats_hacker: error: No such file or directory: 'ats_hacker/tests/test_data/doesnt-exist.txt'\n" assert err == want
def start(self): """Execute command-line instance of ats_hacker.""" args = parse_args() self._process_document(import_file(args.filename[0])) if args.r: self.keyword_counts = remove_words(self.keyword_counts, args.r) if args.o == "json": self._print_json() else: self._print_pretty(args.filename[0])
def test_sucessful_file_open(): filename = "ats_hacker/tests/test_data/simple-job.txt" got = import_file(filename) assert got is not None
def test_successful_file_import(): filename = "ats_hacker/tests/test_data/simple-job.txt" got = import_file(filename) want = "Software Engineer\nSuper Cool Company\nBozeman, MT or Remote\n" assert got == want