Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/structure/test_factory.py
4045 views
1
"""
2
Test of the :mod:`~sage.structure.factory` module.
3
"""
4
5
#*****************************************************************************
6
# Copyright (C) 2008 Robert Bradshaw <[email protected]>
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
#
10
# This code is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
14
#
15
# The full text of the GPL is available at:
16
#
17
# http://www.gnu.org/licenses/
18
#******************************************************************************
19
20
from sage.structure.factory import UniqueFactory
21
22
23
class A:
24
# something we can weakref
25
pass
26
27
class UniqueFactoryTester(UniqueFactory):
28
29
def create_key(self, *args, **kwds):
30
"""
31
EXAMPLES::
32
33
sage: from sage.structure.test_factory import UniqueFactoryTester
34
sage: test_factory = UniqueFactoryTester('foo')
35
sage: test_factory.create_key(1, 2, 3)
36
(1, 2, 3)
37
"""
38
return args
39
40
def create_object(self, version, key, **extra_args):
41
"""
42
EXAMPLES::
43
44
sage: from sage.structure.test_factory import UniqueFactoryTester
45
sage: test_factory = UniqueFactoryTester('foo')
46
sage: test_factory.create_object('version', key=(1, 2, 4))
47
Making object (1, 2, 4)
48
<sage.structure.test_factory.A instance at ...>
49
"""
50
print "Making object", key
51
return A()
52
53
test_factory = UniqueFactoryTester('sage.structure.test_factory.test_factory')
54
55