# -*- coding: utf-8 -*-

import pytest

from freezegun import freeze_time
from jinja2 import Environment, exceptions


@pytest.fixture(scope='session')
def environment():
    return Environment(extensions=['jinja2_time.TimeExtension'])


@pytest.yield_fixture(autouse=True)
def freeze():
    freezer = freeze_time("2015-12-09 23:33:01")
    freezer.start()
    yield
    freezer.stop()


def test_tz_is_required(environment):
    with pytest.raises(exceptions.TemplateSyntaxError):
        environment.from_string('{% now %}')


def test_utc_default_datetime_format(environment):
    template = environment.from_string("{% now 'utc' %}")

    assert template.render() == "2015-12-09"


@pytest.fixture(params=['utc', 'local', 'Europe/Berlin'])
def valid_tz(request):
    return request.param


def test_accept_valid_timezones(environment, valid_tz):
    template = environment.from_string("{% now '" + valid_tz + "' %}")

    assert '2015' in template.render()

@@ -874,32 +874,41 @@
 ent.from_string(
+%0A        
 %22%7B%25 now '%22 + val
@@ -917,20 +917,34 @@
 _tz + %22'
- %25%7D%22
+, '%25Y-%25m' %25%7D%22%0A    
 )%0A%0A    a
@@ -953,18 +953,8 @@
 ert 
-'2015' in 
 temp
@@ -966,9 +966,22 @@
 render()
+ == '2015-12'
 %0A

Improve valid tz test