Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_functools.TestTotalOrdering Class Reference

List of all members.

Public Member Functions

def test_total_ordering_lt
def test_total_ordering_le
def test_total_ordering_gt
def test_total_ordering_ge
def test_total_ordering_no_overwrite
def test_no_operations_defined
def test_bug_10042

Public Attributes

 value

Detailed Description

Definition at line 453 of file test_functools.py.


Member Function Documentation

Definition at line 537 of file test_functools.py.

00537 
00538     def test_bug_10042(self):
00539         @functools.total_ordering
00540         class TestTO:
00541             def __init__(self, value):
00542                 self.value = value
00543             def __eq__(self, other):
00544                 if isinstance(other, TestTO):
00545                     return self.value == other.value
00546                 return False
00547             def __lt__(self, other):
00548                 if isinstance(other, TestTO):
00549                     return self.value < other.value
00550                 raise TypeError
00551         with self.assertRaises(TypeError):
00552             TestTO(8) <= ()

Here is the call graph for this function:

Definition at line 531 of file test_functools.py.

00531 
00532     def test_no_operations_defined(self):
00533         with self.assertRaises(ValueError):
00534             @functools.total_ordering
00535             class A:
00536                 pass

Here is the call graph for this function:

Definition at line 503 of file test_functools.py.

00503 
00504     def test_total_ordering_ge(self):
00505         @functools.total_ordering
00506         class A:
00507             def __init__(self, value):
00508                 self.value = value
00509             def __ge__(self, other):
00510                 return self.value >= other.value
00511             def __eq__(self, other):
00512                 return self.value == other.value
00513         self.assertTrue(A(1) < A(2))
00514         self.assertTrue(A(2) > A(1))
00515         self.assertTrue(A(1) <= A(2))
00516         self.assertTrue(A(2) >= A(1))
00517         self.assertTrue(A(2) <= A(2))
00518         self.assertTrue(A(2) >= A(2))

Here is the call graph for this function:

Definition at line 487 of file test_functools.py.

00487 
00488     def test_total_ordering_gt(self):
00489         @functools.total_ordering
00490         class A:
00491             def __init__(self, value):
00492                 self.value = value
00493             def __gt__(self, other):
00494                 return self.value > other.value
00495             def __eq__(self, other):
00496                 return self.value == other.value
00497         self.assertTrue(A(1) < A(2))
00498         self.assertTrue(A(2) > A(1))
00499         self.assertTrue(A(1) <= A(2))
00500         self.assertTrue(A(2) >= A(1))
00501         self.assertTrue(A(2) <= A(2))
00502         self.assertTrue(A(2) >= A(2))

Here is the call graph for this function:

Definition at line 471 of file test_functools.py.

00471 
00472     def test_total_ordering_le(self):
00473         @functools.total_ordering
00474         class A:
00475             def __init__(self, value):
00476                 self.value = value
00477             def __le__(self, other):
00478                 return self.value <= other.value
00479             def __eq__(self, other):
00480                 return self.value == other.value
00481         self.assertTrue(A(1) < A(2))
00482         self.assertTrue(A(2) > A(1))
00483         self.assertTrue(A(1) <= A(2))
00484         self.assertTrue(A(2) >= A(1))
00485         self.assertTrue(A(2) <= A(2))
00486         self.assertTrue(A(2) >= A(2))

Here is the call graph for this function:

Definition at line 455 of file test_functools.py.

00455 
00456     def test_total_ordering_lt(self):
00457         @functools.total_ordering
00458         class A:
00459             def __init__(self, value):
00460                 self.value = value
00461             def __lt__(self, other):
00462                 return self.value < other.value
00463             def __eq__(self, other):
00464                 return self.value == other.value
00465         self.assertTrue(A(1) < A(2))
00466         self.assertTrue(A(2) > A(1))
00467         self.assertTrue(A(1) <= A(2))
00468         self.assertTrue(A(2) >= A(1))
00469         self.assertTrue(A(2) <= A(2))
00470         self.assertTrue(A(2) >= A(2))

Here is the call graph for this function:

Definition at line 519 of file test_functools.py.

00519 
00520     def test_total_ordering_no_overwrite(self):
00521         # new methods should not overwrite existing
00522         @functools.total_ordering
00523         class A(int):
00524             pass
00525         self.assertTrue(A(1) < A(2))
00526         self.assertTrue(A(2) > A(1))
00527         self.assertTrue(A(1) <= A(2))
00528         self.assertTrue(A(2) >= A(1))
00529         self.assertTrue(A(2) <= A(2))
00530         self.assertTrue(A(2) >= A(2))


Member Data Documentation

Definition at line 459 of file test_functools.py.


The documentation for this class was generated from the following file: