def create_query(self, search): #generate a string with the single parameter - search, using template defined as processAppendQueryTemplate q = processAppendQueryTemplate.generate( Context(search=search)).render() #print the query #print q return q
def test_import_in_def(self): suite = Suite("""def fun(): from itertools import repeat return repeat(1, 3) """) data = Context() suite.execute(data) assert 'repeat' not in data self.assertEqual([1, 1, 1], list(data['fun']()))
def test_import_in_def(self): suite = Suite("""def fun(): from itertools import ifilter return ifilter(None, range(3)) """) data = Context() suite.execute(data) assert 'ifilter' not in data self.assertEqual([1, 2], list(data['fun']()))
def test_copy(self): # create a non-trivial context with some dummy # frames, match templates and py:choice stacks. orig_ctxt = Context(a=5, b=6) orig_ctxt.push({'c': 7}) orig_ctxt._match_templates.append(object()) orig_ctxt._choice_stack.append(object()) ctxt = orig_ctxt.copy() self.assertNotEqual(id(orig_ctxt), id(ctxt)) self.assertEqual(repr(orig_ctxt), repr(ctxt)) self.assertEqual(orig_ctxt._match_templates, ctxt._match_templates) self.assertEqual(orig_ctxt._choice_stack, ctxt._choice_stack)
def test_import_star(self): suite = Suite("from itertools import *") data = Context() suite.execute(data) assert 'ifilter' in data
def create_query(self, search): q = downstreamQueryTemplate.generate(Context(search=search)).render() return q
def create_query(self, search): q = processAppendQueryTemplate.generate( Context(search=search)).render() return q