From 21aa4a383b86e2afda8f8a79d0d2159526c744da Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 23 May 2017 17:01:34 +0100 Subject: [PATCH] renaming Module > PyObect, fix #9 --- pydantic/types.py | 4 ++-- tests/test_types.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pydantic/types.py b/pydantic/types.py index 10a1830..742e252 100644 --- a/pydantic/types.py +++ b/pydantic/types.py @@ -13,7 +13,7 @@ __all__ = [ 'constr', 'EmailStr', 'NameEmail', - 'Module', + 'PyObject', 'DSN', 'ConstrainedInt', 'conint', @@ -95,7 +95,7 @@ def constr(*, min_length=0, max_length=2**16, curtail_length=None, regex=None) - return type('ConstrainedStrValue', (ConstrainedStr,), namespace) -class Module: +class PyObject: validate_always = True @classmethod diff --git a/tests/test_types.py b/tests/test_types.py index f60664f..8887f6a 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -5,7 +5,7 @@ from enum import Enum, IntEnum import pytest -from pydantic import (DSN, BaseModel, EmailStr, Module, NameEmail, NegativeInt, PositiveInt, ValidationError, +from pydantic import (DSN, BaseModel, EmailStr, NameEmail, NegativeInt, PositiveInt, PyObject, ValidationError, conint, constr) @@ -69,15 +69,15 @@ def test_dsn_no_driver(): assert '"db_driver" field may not be missing or None' in str(exc_info.value) -class ModuleModel(BaseModel): - module: Module = 'os.path' +class PyObjectModel(BaseModel): + module: PyObject = 'os.path' def test_module_import(): - m = ModuleModel() + m = PyObjectModel() assert m.module == os.path with pytest.raises(ValidationError) as exc_info: - ModuleModel(module='foobar') + PyObjectModel(module='foobar') assert '"foobar" doesn\'t look like a module path' in str(exc_info.value)