Пример #1
0
def run_shell(context=Context(), history_file=os.path.expanduser('~/.django-template-repl-history')):
    from template_repl.repl import TemplateREPL

    if os.path.exists(history_file):
        readline.read_history_file(history_file)
    console = TemplateREPL(context=context)
    console.interact('\033[92mdjango-template-repl %s\033[0m' % get_version())
    sys.stderr.write('\nkthxbai!\n')
    readline.write_history_file(history_file)
Пример #2
0
def mock_interaction(commands, context={}):
    context = Context(context)
    output = ''
    output_buffer = StringIO()
    console = TemplateREPL(output=output_buffer, context=context)
    for command in commands:
        console.push(command)
    output_buffer.seek(0)
    output = output_buffer.read()
    return output
Пример #3
0
def mock_interaction(commands, context={}):
    context = Context(context)
    output = ''
    output_buffer = StringIO()
    console = TemplateREPL(output=output_buffer, context=context)
    for command in commands:
        console.push(command)
    output_buffer.seek(0)
    output = output_buffer.read()
    return output
Пример #4
0
 def setUp(self):
     self.repl = TemplateREPL(
         context=Context({
             'food': ['tacos', 'ice cream', 'sushi'],
             'folly': 'fail',
             'banana': 'nomnom!banana!',
         }))