

def test_datetime_autonow(self):
    schema = schemas.DateTimeField.definition()
    definition = schema.deserialize({
        'name': 'branch',
        'type': 'datetime',
        'autonow': True,
    })
    validator = schemas.DateTimeField.validation(**definition)
    defaulted = validator.deserialize(None)
    self.assertTrue(((datetime.datetime.now() - defaulted).seconds < 1))
    defaulted = validator.deserialize('')
    self.assertTrue(((datetime.datetime.now() - defaulted).seconds < 1))

dataset/ETHPy150Open spiral-project/daybed/daybed/tests/test_schemas_base.py DateFieldTests.test_datetime_autonow/original