[Twisted-Python] slightly silly hack

Ever wanted to execute your trial tests as though they were commands? You can use tab completion in bash, for example: $ ./amdlib/storage/test/test_storefile.py -s It's easy! Give your file executable permission and at the top of the file type this line: "#!/usr/bin/env python". At the bottom type: """ if __name__ == "__main__": import os, sys mods = [] fullname = os.path.realpath(os.path.abspath(__file__)) for pathel in sys.path: fullnameofpathel = os.path.realpath(os.path.abspath(pathel)) if fullname.startswith(fullnameofpathel): relname = fullname[len(fullnameofpathel):] mod = (os.path.splitext(relname)[0]).replace(os.sep, '.').strip('.') mods.append(mod) mods.sort(cmp=lambda x, y: cmp(len(x), len(y))) mods.reverse() for mod in mods: cmdstr = "trial %s %s" % (' '.join(sys.argv[1:]), mod,) print cmdstr if os.system(cmdstr) == 0: break """ Regards, Zooko
participants (1)
-
zooko@zooko.com