Singleton Model Error while running tests

Good afternoon everyone,

I’m currently working on building a test environment (using ModuleTestCase suite tests).
One of my models calls a fonction that requires a instance of singleton model - code below.

        >>> my_model_config= Pool().get('my_model.configuration').get_singleton()
        >>> value = my_model_config.field_boolean

The returned Error is the following :

	AttributeError: 'NoneType' object has no attribute 'field_boolean'

I understand that my_model_config is None, cause get_singleton function did not find any matching
object. But when I try to manually search for it inside my test environment, I successfully find an
instance of my_model_config.

	>>> test_my_model_config = pool.get('my_model.configuration').search([], limit=1)[0]
	>>> print(test_my_model_config if test_my_model_config != None)

Here is the definition of my_model.configuration :

	>>> from trytond.model import ModelView, ModelSQL, ModelSingleton

	>>> __all__ = [
    	>>> 	'Configuration',
    	>>> 	]

	>>> class Configuration(ModelSingleton, modelSQL, modelView):
    	>>> 	'My Model Configuration'

    	>>> 	__name__ = 'my_model.configuration'

    	>>> 	field_boolean = fields.Boolean('Attribute Boolean')

I do not get where is the issue here. Hope that you can help me !
Thank you by advance.

This is because Tryton emulates a singleton even if there are no record saved in the table.
Indeed you should not use get_singleton because it returns only saved singleton. Instead you should always instantiate a singleton with for example the id 1 (common practice).