Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from hiaselhans/resize_table
dynamically resize the table matrix on set_value
- Loading branch information
Showing
5 changed files
with
74 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import random | ||
|
||
from base import PyexcelSheetBase | ||
|
||
|
||
class TestSheetAccess(PyexcelSheetBase): | ||
@staticmethod | ||
def get_random_char(): | ||
i = random.randint(97, 122) | ||
return chr(i) | ||
|
||
def test_out_of_bounds_write(self): | ||
value = self.get_random_char() | ||
column = self.get_random_char() + self.get_random_char() | ||
cell = column + str(random.randint(1, 30)) | ||
self.sheet[cell] = value | ||
|
||
self.assertEqual(value, self.sheet[cell]) | ||
|
||
def test_out_of_bounds_read(self): | ||
with self.assertRaises(IndexError): | ||
self.sheet[0, 20] | ||
|
||
with self.assertRaises(IndexError): | ||
self.sheet[20, 0] | ||
|
||
def test_column_edge_case(self): | ||
column = self.sheet.number_of_columns()-1 | ||
|
||
self.assertEqual(self.sheet[0, column], f"0_{column}") | ||
with self.assertRaises(IndexError): | ||
self.sheet[0, column+1] | ||
|
||
def test_row_edge_case(self): | ||
row = self.sheet.number_of_rows()-1 | ||
|
||
self.assertEqual(self.sheet[row, 0], f"{row}_0") | ||
with self.assertRaises(IndexError): | ||
self.sheet[row+1, 0] |