Skip to content

Commit 5beebad

Browse files
committed
Replacing uses of sort() with sorted in HappyBase system tests.
1 parent 9304e78 commit 5beebad

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

system_tests/bigtable_happybase.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ def test_rows(self):
250250
table.put(ROW_KEY1, row1_data)
251251
table.put(ROW_KEY2, row2_data)
252252

253-
rows = table.rows([ROW_KEY1, ROW_KEY2])
254-
rows.sort(key=_FIRST_ELT)
255-
253+
rows = sorted(table.rows([ROW_KEY1, ROW_KEY2]), key=_FIRST_ELT)
256254
row1, row2 = rows
257255
self.assertEqual(row1, (ROW_KEY1, row1_data))
258256
self.assertEqual(row2, (ROW_KEY2, row2_data))
@@ -272,9 +270,8 @@ def test_rows_with_returned_timestamps(self):
272270
batch.put(ROW_KEY1, row1_data)
273271
batch.put(ROW_KEY2, row2_data)
274272

275-
rows = table.rows([ROW_KEY1, ROW_KEY2], include_timestamp=True)
276-
rows.sort(key=_FIRST_ELT)
277-
273+
rows = sorted(table.rows([ROW_KEY1, ROW_KEY2], include_timestamp=True),
274+
key=_FIRST_ELT)
278275
row1, row2 = rows
279276
self.assertEqual(row1[0], ROW_KEY1)
280277
self.assertEqual(row2[0], ROW_KEY2)
@@ -313,8 +310,8 @@ def test_rows_with_columns(self):
313310
table.put(ROW_KEY2, row2_data)
314311

315312
# Filter a single column present in both rows.
316-
rows_col1 = table.rows([ROW_KEY1, ROW_KEY2], columns=[COL1])
317-
rows_col1.sort(key=_FIRST_ELT)
313+
rows_col1 = sorted(table.rows([ROW_KEY1, ROW_KEY2], columns=[COL1]),
314+
key=_FIRST_ELT)
318315
row1, row2 = rows_col1
319316
self.assertEqual(row1, (ROW_KEY1, {COL1: value1}))
320317
self.assertEqual(row2, (ROW_KEY2, {COL1: value3}))
@@ -324,8 +321,9 @@ def test_rows_with_columns(self):
324321
self.assertEqual(rows_col2, [(ROW_KEY1, {COL2: value2})])
325322

326323
# Filter a column family.
327-
rows_col_fam1 = table.rows([ROW_KEY1, ROW_KEY2], columns=[COL_FAM1])
328-
rows_col_fam1.sort(key=_FIRST_ELT)
324+
rows_col_fam1 = sorted(
325+
table.rows([ROW_KEY1, ROW_KEY2], columns=[COL_FAM1]),
326+
key=_FIRST_ELT)
329327
row1, row2 = rows_col_fam1
330328
self.assertEqual(row1, (ROW_KEY1, row1_data))
331329
self.assertEqual(row2, (ROW_KEY2, row2_data))
@@ -335,17 +333,17 @@ def test_rows_with_columns(self):
335333
self.assertEqual(rows_col_fam2, [])
336334

337335
# Filter a column family that overlaps with a column.
338-
rows_col_fam_overlap1 = table.rows([ROW_KEY1, ROW_KEY2],
339-
columns=[COL1, COL_FAM1])
340-
rows_col_fam_overlap1.sort(key=_FIRST_ELT)
336+
rows_col_fam_overlap1 = sorted(table.rows([ROW_KEY1, ROW_KEY2],
337+
columns=[COL1, COL_FAM1]),
338+
key=_FIRST_ELT)
341339
row1, row2 = rows_col_fam_overlap1
342340
self.assertEqual(row1, (ROW_KEY1, row1_data))
343341
self.assertEqual(row2, (ROW_KEY2, row2_data))
344342

345343
# Filter a column family that overlaps with a column (opposite order).
346-
rows_col_fam_overlap2 = table.rows([ROW_KEY1, ROW_KEY2],
347-
columns=[COL_FAM1, COL1])
348-
rows_col_fam_overlap2.sort(key=_FIRST_ELT)
344+
rows_col_fam_overlap2 = sorted(table.rows([ROW_KEY1, ROW_KEY2],
345+
columns=[COL_FAM1, COL1]),
346+
key=_FIRST_ELT)
349347
row1, row2 = rows_col_fam_overlap2
350348
self.assertEqual(row1, (ROW_KEY1, row1_data))
351349
self.assertEqual(row2, (ROW_KEY2, row2_data))
@@ -366,8 +364,8 @@ def test_rows_with_timestamp(self):
366364
table.put(ROW_KEY1, {COL4: value4})
367365

368366
# Just grab the timestamps
369-
rows = table.rows([ROW_KEY1, ROW_KEY2], include_timestamp=True)
370-
rows.sort(key=_FIRST_ELT)
367+
rows = sorted(table.rows([ROW_KEY1, ROW_KEY2], include_timestamp=True),
368+
key=_FIRST_ELT)
371369
row1, row2 = rows
372370
self.assertEqual(row1[0], ROW_KEY1)
373371
self.assertEqual(row2[0], ROW_KEY2)
@@ -382,17 +380,17 @@ def test_rows_with_timestamp(self):
382380
self.assertTrue(ts1 < ts2 < ts3 < ts4)
383381

384382
# Rows before the third timestamp (assumes exclusive endpoint).
385-
rows = table.rows([ROW_KEY1, ROW_KEY2], timestamp=ts3,
386-
include_timestamp=True)
387-
rows.sort(key=_FIRST_ELT)
383+
rows = sorted(table.rows([ROW_KEY1, ROW_KEY2], timestamp=ts3,
384+
include_timestamp=True),
385+
key=_FIRST_ELT)
388386
row1, row2 = rows
389387
self.assertEqual(row1, (ROW_KEY1, {COL1: (value1, ts1)}))
390388
self.assertEqual(row2, (ROW_KEY2, {COL1: (value2, ts2)}))
391389

392390
# All writes (bump the exclusive endpoint by 1 millisecond).
393-
rows = table.rows([ROW_KEY1, ROW_KEY2], timestamp=ts4 + 1,
394-
include_timestamp=True)
395-
rows.sort(key=_FIRST_ELT)
391+
rows = sorted(table.rows([ROW_KEY1, ROW_KEY2], timestamp=ts4 + 1,
392+
include_timestamp=True),
393+
key=_FIRST_ELT)
396394
row1, row2 = rows
397395
row1_all_data = {
398396
COL1: (value1, ts1),

0 commit comments

Comments
 (0)