引言
在读一本书《Learn Python Programming》1的第8章,按照书中的讲解先后安装了marshmallow
和pytest
第三方库,j进而按照书中的代码结构和代码在ch08文件夹下运行pytest tests
,出现如下错误:
ch08中的api.py的代码为:
# ch08/api.py
'''
This program needs: pip install marshmallow; pip install pytest
'''
import os
import csv
from copy import deepcopy
from marshmallow import Schema, fields, pre_load
from marshmallow.validate import Length, Range
class UserSchema(Schema):
''' Represent a *valid* user. '''
email = fields.Email(required=True)
name = fields.String(required=True, validate=Length(min=1))
age = fields.Integer(required=True, validate=Range(min=18, max=65))
role = fields.String()
@pre_load(pass_many=False)