'#15849 -- ifchanged should be thread-safe.'

def test_ifchanged_concurrency(self):

    template = self.engine.from_string('[0{%    for    x    in    foo    %},{%    with    var=get_value    %}{%    ifchanged    %}{{    var    }}{%    endifchanged    %}{%    endwith    %}{%    endfor    %}]')
    def gen():
        (yield 1)
        (yield 2)
        iter2 = iter([1, 2, 3])
        output2 = template.render(Context({'foo': range(3), 'get_value': (lambda : next(iter2))}))
        self.assertEqual(output2, '[0,1,2,3]', 'Expected    [0,1,2,3]    in    second    parallel    template,    got    {}'.format(output2))
        (yield 3)
    gen1 = gen()
    output1 = template.render(Context({'foo': range(3), 'get_value': (lambda : next(gen1))}))
    self.assertEqual(output1, '[0,1,2,3]', 'Expected    [0,1,2,3]    in    first    template,    got    {}'.format(output1))
