@@ -64,11 +64,11 @@ class MyUnsortedTable(TestTable):
64
64
{'alpha' : "aaa" , 'beta' : "zzz" , 'n' : 2 },
65
65
{'alpha' : "zzz" , 'beta' : "aaa" , 'n' : 3 }]
66
66
67
- # unsorted (default) preserves order
68
- assert_equal (1 , MyUnsortedTable (test_data ).rows [ 0 ][ 'n' ] )
69
- assert_equal (1 , MyUnsortedTable (test_data , order_by = None ).rows [ 0 ][ 'n' ] )
70
- assert_equal (1 , MyUnsortedTable (test_data , order_by = [] ).rows [ 0 ][ 'n' ] )
71
- assert_equal (1 , MyUnsortedTable (test_data , order_by = () ).rows [ 0 ][ 'n' ] )
67
+ # various different ways to say the same thing: don't sort
68
+ assert_equal (MyUnsortedTable (test_data ).order_by , () )
69
+ assert_equal (MyUnsortedTable (test_data , order_by = None ).order_by , () )
70
+ assert_equal (MyUnsortedTable (test_data , order_by = [] ).order_by , () )
71
+ assert_equal (MyUnsortedTable (test_data , order_by = () ).order_by , () )
72
72
73
73
# values of order_by are wrapped in tuples before being returned
74
74
assert_equal (('alpha' ,), MyUnsortedTable ([], order_by = 'alpha' ).order_by )
@@ -80,10 +80,6 @@ class MyUnsortedTable(TestTable):
80
80
table .order_by = 'alpha'
81
81
assert_equal (('alpha' ,), table .order_by )
82
82
83
- # data can be sorted by any column
84
- assert_equal (2 , MyUnsortedTable (test_data , order_by = 'alpha' ).rows [0 ]['n' ])
85
- assert_equal (3 , MyUnsortedTable (test_data , order_by = 'beta' ).rows [0 ]['n' ])
86
-
87
83
# default sort order can be specified in table options
88
84
class MySortedTable (MyUnsortedTable ):
89
85
class Meta :
@@ -92,18 +88,15 @@ class Meta:
92
88
# order_by is inherited from the options if not explitly set
93
89
table = MySortedTable (test_data )
94
90
assert_equal (('alpha' ,), table .order_by )
95
- assert_equal (2 , table .rows [0 ]['n' ])
96
91
97
92
# ...but can be overloaded at __init___
98
93
table = MySortedTable (test_data , order_by = 'beta' )
99
94
assert_equal (('beta' ,), table .order_by )
100
- assert_equal (3 , table .rows [0 ]['n' ])
101
95
102
96
# ...or rewritten later
103
97
table = MySortedTable (test_data )
104
98
table .order_by = 'beta'
105
99
assert_equal (('beta' ,), table .order_by )
106
- assert_equal (3 , table .rows [0 ]['n' ])
107
100
108
101
# ...or reset to None (unsorted), ignoring the table default
109
102
table = MySortedTable (test_data , order_by = None )
0 commit comments