# Path: tests/common.py
# class DummyPostData(dict):
#     def getlist(self, key):
#         v = self[key]
#         if not isinstance(v, (list, tuple)):
#             v = [v]
#         return v


import datetime
import hashlib
import hmac
import pytest
from contextlib import contextmanager
from functools import partial
from tests.common import DummyPostData
from wtforms.csrf.core import CSRF
from wtforms.csrf.session import SessionCSRF
from wtforms.fields import StringField
from wtforms.form import Form
        cls.pinned_time = value
        yield
        cls.pinned_time = original

    def now(self):
        return self.pinned_time


class SimplePopulateObject:
    a = None
    csrf_token = None


class TestDummyCSRF:
    class F(Form):
        class Meta:
            csrf = True
            csrf_class = DummyCSRF

        a = StringField()

    def test_base_class(self):
        with pytest.raises(NotImplementedError):
            self.F(meta={"csrf_class": CSRF})

    def test_basic_impl(self):
        form = self.F()
        assert "csrf_token" in form
        assert not form.validate()
        assert form.csrf_token._value() == "dummytoken"

# Path: tests/common.py
# class DummyPostData(dict):
#     def getlist(self, key):
#         v = self[key]
#         if not isinstance(v, (list, tuple)):
#             v = [v]
#         return v


# Path: tests/test_csrf.py
import datetime
import hashlib
import hmac
import pytest
from contextlib import contextmanager
from functools import partial
from tests.common import DummyPostData
from wtforms.csrf.core import CSRF
from wtforms.csrf.session import SessionCSRF
from wtforms.fields import StringField
from wtforms.form import Form

        cls.pinned_time = value
        yield
        cls.pinned_time = original

    def now(self):
        return self.pinned_time


class SimplePopulateObject:
    a = None
    csrf_token = None


class TestDummyCSRF:
    class F(Form):
        class Meta:
            csrf = True
            csrf_class = DummyCSRF

        a = StringField()

    def test_base_class(self):
        with pytest.raises(NotImplementedError):
            self.F(meta={"csrf_class": CSRF})

    def test_basic_impl(self):
        form = self.F()
        assert "csrf_token" in form
        assert not form.validate()
        assert form.csrf_token._value() == "dummytoken"

        form = self.F(DummyPostData(csrf_token="dummytoken"))