"""
Test of the :mod:`~sage.structure.factory` module.
"""
from sage.structure.factory import UniqueFactory
class A:
pass
class UniqueFactoryTester(UniqueFactory):
def create_key(self, *args, **kwds):
"""
EXAMPLES::
sage: from sage.structure.test_factory import UniqueFactoryTester
sage: test_factory = UniqueFactoryTester('foo')
sage: test_factory.create_key(1, 2, 3)
(1, 2, 3)
"""
return args
def create_object(self, version, key, **extra_args):
"""
EXAMPLES::
sage: from sage.structure.test_factory import UniqueFactoryTester
sage: test_factory = UniqueFactoryTester('foo')
sage: test_factory.create_object('version', key=(1, 2, 4))
Making object (1, 2, 4)
<sage.structure.test_factory.A instance at ...>
"""
print "Making object", key
return A()
test_factory = UniqueFactoryTester('sage.structure.test_factory.test_factory')