renaming Module > PyObect, fix #9

This commit is contained in:
Samuel Colvin
2017-05-23 17:01:34 +01:00
parent 90a2b6bfe3
commit 21aa4a383b
2 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -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
+5 -5
View File
@@ -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)