def setup_docs(self): """ Processes args which may be doc objects or filenames with wildcards. """ if not hasattr(self, 'docs'): self.docs = [] for arg in self.args: self.log.debug("Processing arg %s" % arg) if isinstance(arg, Doc) or isinstance(arg, PatternDoc): doc = arg elif isinstance(arg, list): if not isinstance(arg[0], basestring): raise Exception("First arg %s should be a string" % arg[0]) if not isinstance(arg[1], dict): raise Exception("Second arg %s should be a dict" % arg[1]) if not "*" in arg[0]: doc = Doc(arg[0], **arg[1]) else: # This is a pattern doc or real doc TODO better way to verify? doc = PatternDoc(arg[0], **arg[1]) elif isinstance(arg, basestring): doc = PatternDoc(arg) else: raise Exception("unknown arg type %s for arg %s" % (arg.__class__.__name__, arg)) doc.runner = self doc.setup() self.docs.append(doc)
def test_attempt_write_outside_project_root(): with wrap() as wrapper: try: doc = Doc("../../example.txt", wrapper, [], contents="hello") doc.setup() doc.setup_datas() assert False, 'should raise UserFeedback' except dexy.exceptions.UserFeedback as e: print str(e) assert 'trying to write' in str(e)
def test_attempt_write_outside_project_root(): with wrap() as wrapper: try: doc = Doc("../../example.txt", wrapper, [], contents = "hello") doc.setup() doc.setup_datas() assert False, 'should raise UserFeedback' except dexy.exceptions.UserFeedback as e: print str(e) assert 'trying to write' in str(e)