Python mongoengine 模块,EmailField() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用mongoengine.EmailField()

项目:mongoengine_utils    作者:aiscenblue    | 项目源码 | 文件源码
def setUp(self):
        """Setup."""
        self.maxDiff = None

        class User(gj.Document):
            name = db.StringField()
            email = db.EmailField()

        class TestDocument(gj.Document):
            value = db.StringField()
            author = gj.FollowReferenceField(User)
            contributors = db.ListField(gj.FollowReferenceField(User))

        self.user_model_cls = User
        self.test_model_cls = TestDocument
        self.users_data = [
            {
                "id": ObjectId(),
                "name": ("Test Example {}").format(counter),
                "email": ("test{}@example.com").format(counter)
            } for counter in range(3)
        ]
        self.tests_data = [
            {
                "id": ObjectId(),
                "value": ("test{}").format(counter),
                "author": self.users_data[counter]["id"],
                "contributors": [
                    user["id"] for (index, user) in enumerate(self.users_data)
                    if index != counter
                ]
            } for counter in range(3)
        ]