DEV Community

Discussion on: PyTest with Django REST Framework: From Zero to Hero

Collapse
 
emiliocrespi profile image
EmilioCrespi • Edited

Hi thanks for you very useful post, I didn't get how can this snippet works, if FilledTransactionFactory.build() does not create database obj, t.id will be None. I missed something?

@pytest.mark.unit
def test_serialized_data(self):
    t = FilledTransactionFactory.build()
    valid_serialized_data = {
        'id': t.id.hashid,
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sherlockcodes profile image
Lucas Miguel

It does build an object, it just doesn't hit the database to store it. It's like instantiating a common python object