mirror of
				https://github.com/fastapi/sqlmodel.git
				synced 2025-11-04 06:37:29 +08:00 
			
		
		
		
	Co-authored-by: Mohamed Farahat <farahats9@yahoo.com> Co-authored-by: Stefan Borer <stefan.borer@gmail.com> Co-authored-by: Peter Landry <peter.landry@gmail.com> Co-authored-by: Anton De Meester <antondemeester+github@gmail.com>
		
			
				
	
	
		
			31 lines
		
	
	
		
			690 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			690 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import pytest
 | 
						|
from sqlmodel import SQLModel
 | 
						|
 | 
						|
 | 
						|
class Item(SQLModel):
 | 
						|
    name: str
 | 
						|
 | 
						|
 | 
						|
class SubItem(Item):
 | 
						|
    password: str
 | 
						|
 | 
						|
 | 
						|
def test_deprecated_from_orm_inheritance():
 | 
						|
    new_item = SubItem(name="Hello", password="secret")
 | 
						|
    with pytest.warns(DeprecationWarning):
 | 
						|
        item = Item.from_orm(new_item)
 | 
						|
    assert item.name == "Hello"
 | 
						|
    assert not hasattr(item, "password")
 | 
						|
 | 
						|
 | 
						|
def test_deprecated_parse_obj():
 | 
						|
    with pytest.warns(DeprecationWarning):
 | 
						|
        item = Item.parse_obj({"name": "Hello"})
 | 
						|
    assert item.name == "Hello"
 | 
						|
 | 
						|
 | 
						|
def test_deprecated_dict():
 | 
						|
    with pytest.warns(DeprecationWarning):
 | 
						|
        data = Item(name="Hello").dict()
 | 
						|
    assert data == {"name": "Hello"}
 |