Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Rename test classes in nested_class_test
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Mar 25, 2022
1 parent 9efaf59 commit e61cdbb
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/sage/misc/nested_class_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
Currently pickling fails for parents using nested classes (typically
for categories), but deriving only from Parent::
sage: from sage.misc.nested_class_test import TestParent1, TestParent2, TestParent3, TestParent4
sage: P = TestParent1()
sage: from sage.misc.nested_class_test import _TestParent1, _TestParent2, _TestParent3, _TestParent4
sage: P = _TestParent1()
sage: TestSuite(P).run()
Failure ...
The following tests failed: _test_elements, _test_pickling
They actually need to be in the NestedClassMetaclass. However, due to
a technical detail, this is currently not directly supported::
sage: P = TestParent2()
sage: P = _TestParent2()
Traceback (most recent call last):
...
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Expand All @@ -28,13 +28,13 @@
Instead, the easiest is to inherit from UniqueRepresentation, which is
what you want to do anyway most of the time::
sage: P = TestParent3()
sage: P = _TestParent3()
sage: TestSuite(P).run()
This is what all Sage's parents using categories currently do. An
alternative is to use ClasscallMetaclass as metaclass::
sage: P = TestParent4()
sage: P = _TestParent4()
sage: TestSuite(P).run()
"""
Expand All @@ -54,13 +54,13 @@
from sage.misc.nested_class import NestedClassMetaclass


class TestParent1(Parent):
class _TestParent1(Parent):
def __init__(self):
"""
EXAMPLES::
sage: sage.misc.nested_class_test.TestParent1()
<sage.misc.nested_class_test.TestParent1_with_category object at ...>
sage: sage.misc.nested_class_test._TestParent1()
<sage.misc.nested_class_test._TestParent1_with_category object at ...>
"""
from sage.categories.sets_cat import Sets
Parent.__init__(self, category = Sets())
Expand All @@ -69,12 +69,12 @@ class Element(ElementWrapper):
pass


class TestParent2(Parent, metaclass=NestedClassMetaclass):
class _TestParent2(Parent, metaclass=NestedClassMetaclass):
def __init__(self):
"""
EXAMPLES::
sage: sage.misc.nested_class_test.TestParent2()
sage: sage.misc.nested_class_test._TestParent2()
Traceback (most recent call last):
...
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Expand All @@ -86,14 +86,14 @@ class Element(ElementWrapper):
pass


class TestParent3(UniqueRepresentation, Parent):
class _TestParent3(UniqueRepresentation, Parent):

def __init__(self):
"""
EXAMPLES::
sage: sage.misc.nested_class_test.TestParent3()
<sage.misc.nested_class_test.TestParent3_with_category object at ...>
sage: sage.misc.nested_class_test._TestParent3()
<sage.misc.nested_class_test._TestParent3_with_category object at ...>
"""
from sage.categories.sets_cat import Sets
Parent.__init__(self, category = Sets())
Expand All @@ -102,13 +102,13 @@ class Element(ElementWrapper):
pass


class TestParent4(Parent, metaclass=ClasscallMetaclass):
class _TestParent4(Parent, metaclass=ClasscallMetaclass):
def __init__(self):
"""
EXAMPLES::
sage: sage.misc.nested_class_test.TestParent4()
<sage.misc.nested_class_test.TestParent4_with_category object at ...>
sage: sage.misc.nested_class_test._TestParent4()
<sage.misc.nested_class_test._TestParent4_with_category object at ...>
"""
from sage.categories.sets_cat import Sets
Parent.__init__(self, category=Sets())
Expand All @@ -117,8 +117,8 @@ def __eq__(self, other):
"""
EXAMPLES::
sage: from sage.misc.nested_class_test import TestParent4
sage: TestParent4() == TestParent4()
sage: from sage.misc.nested_class_test import _TestParent4
sage: _TestParent4() == _TestParent4()
True
"""
return self.__class__ == other.__class__
Expand All @@ -127,8 +127,8 @@ def __ne__(self, other):
"""
EXAMPLES::
sage: from sage.misc.nested_class_test import TestParent4
sage: TestParent4() != TestParent4()
sage: from sage.misc.nested_class_test import _TestParent4
sage: _TestParent4() != _TestParent4()
False
"""
return self.__class__ != other.__class__
Expand All @@ -139,8 +139,8 @@ def __hash__(self):
EXAMPLES::
sage: from sage.misc.nested_class_test import TestParent4
sage: hash(TestParent4()) == hash(TestParent4())
sage: from sage.misc.nested_class_test import _TestParent4
sage: hash(_TestParent4()) == hash(_TestParent4())
True
"""
return hash(8960522744683456048)
Expand Down Expand Up @@ -215,7 +215,7 @@ class CMeta(object):
CMeta = ALBMeta.CMeta


class TestNestedParent(UniqueRepresentation, Parent):
class _TestNestedParent(UniqueRepresentation, Parent):
"""
This is a dummy for testing source inspection of nested classes.
Expand Down

0 comments on commit e61cdbb

Please sign in to comment.