Ticket #14278: trac_14278-doctest.patch

File trac_14278-doctest.patch, 1.6 KB (added by SimonKing, 7 years ago)
  • sage/structure/unique_representation.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1363818232 -3600
    # Node ID 29efdbc99b1f098c8bdacd433f7730b3e7e2a09b
    # Parent  e134bc6c6c082ce2a49c649374ead4bf773ab26d
    #14278: Add one test.
    
    diff --git a/sage/structure/unique_representation.py b/sage/structure/unique_representation.py
    a b  
    491491            sage: c is C(3)
    492492            False
    493493
     494        Here is a similar example, using a private classcall in the class
     495        ``B``, which is not inherited by ``C``::
     496
     497            sage: class A(UniqueRepresentation):
     498            ...    def __init__(self, x):
     499            ...        pass
     500            sage: class B(A):
     501            ...    @staticmethod
     502            ...    def __classcall_private__(cls, *args, **kwds):
     503            ...        print "Private B"
     504            ...        return super(B,cls).__classcall__(cls,*args,**kwds)
     505            sage: class C(B): pass
     506            sage: a = A(1)
     507            sage: b = B(2)
     508            Private B
     509            sage: c = C(3)
     510            sage: a is A(1)
     511            True
     512            sage: b is B(2)
     513            Private B
     514            True
     515            sage: c is C(3)
     516            True
     517            sage: B._clear_cache_()
     518
     519        Again, all instances of (sub-classes of) ``B`` have disappeared
     520        from the cache::
     521
     522            sage: a is A(1)
     523            True
     524            sage: b is B(2)
     525            Private B
     526            False
     527            sage: c is C(3)
     528            False
     529
    494530        """
    495531        del_list = []
    496532        cache = None