def test_census_words(self): a = ety.census(['alphabet', 'avocado', 'guitar']) b = ety.census('alphabet avocado guitar') self.assertEqual(a, b) self.assertTrue(ety.Word('avocado') in a.words) with self.assertRaises(ValueError): ety.census(['valid', ety.Word('stillvalid'), 12345])
def test_census_words(self): a = ety.census(["alphabet", "avocado", "guitar"]) b = ety.census("alphabet avocado guitar") self.assertEqual(a, b) self.assertTrue(ety.Word("avocado") in a.words) with self.assertRaises(ValueError): ety.census(["valid", ety.Word("stillvalid"), 12345])
def cli(): """ Command line interface :return: Exit code """ parser = argparse.ArgumentParser(prog="ety") parser.add_argument("words", type=str, nargs='+', help="the search word(s)") parser.add_argument("-r", "--recursive", help="search origins recursively", action="store_true") parser.add_argument("-t", "--tree", help="display etymology tree", action="store_true") args = parser.parse_args() output = '' for word in args.words: source_word = ety.Word(word, color=True) roots = ety.origins(word, recursive=args.recursive) if not roots: print("No origins found for word: {}".format(word)) continue # Bullet point: '\u2022' if args.tree: output += '%s\n\n' % str(ety.tree(source_word)) else: output += '\n\n%s\n \u2022 ' % source_word output += '\n \u2022 '.join(root.pretty for root in roots) print(output.strip()) return 0
def test_word_equal(self): a = ety.Word("electronic") b = ety.Word("electronic", language="lat") c = ety.Word("electrinus") self.assertNotEqual(a, b) self.assertNotEqual(a, c)
def test_word_len(self): word = ety.random_word().word self.assertEqual(len(ety.Word(word)), len(word))
def test_word_equal(self): a = ety.Word('electronic') b = ety.Word('electronic', language='lat') c = ety.Word('electrinus') self.assertNotEqual(a, b) self.assertNotEqual(a, c)