コード例 #1
0
 def test_is_not_superset(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("A1:D4")
     assert cr1.issuperset(cr2) is False
コード例 #2
0
 def test_expand(self, CellRange):
     cr = CellRange("E5:K10")
     cr.expand(right=2, down=2, left=1, up=2)
     assert cr.coord == "D3:M12"
コード例 #3
0
 def test_size(self, CellRange):
     cr = CellRange("E5:K10")
     assert cr.size == {'columns': 7, 'rows': 6}
コード例 #4
0
 def test_shift(self, CellRange):
     cr = CellRange("A1:B4")
     cr.shift(1, 2)
     assert cr.coord == "B3:C6"
コード例 #5
0
 def test_union(self, CellRange):
     cr1 = CellRange("A1:D4")
     cr2 = CellRange("E5:K10")
     cr3 = cr1.union(cr2)
     assert cr3.bounds == (1, 1, 11, 10)
コード例 #6
0
 def test_str(self, CellRange):
     cr = CellRange("'Sheet 1'!$A$1:B4")
     assert str(cr) == "'Sheet 1'!A1:B4"
     cr = CellRange("A1")
     assert str(cr) == "A1"
コード例 #7
0
 def test_ne(self, CellRange):
     cr1 = CellRange("'Sheet 1'!$A$1:B4")
     cr2 = CellRange("Sheet1!$A$1:B4")
     assert cr1 != cr2
コード例 #8
0
 def test_gt(self, CellRange):
     cr1 = CellRange("A1:F5")
     cr2 = CellRange("A2:F4")
     assert cr1 > cr2
コード例 #9
0
 def test_ctor(self, MultiCellRange, CellRange):
     cr = CellRange("A1")
     cells = MultiCellRange(ranges=[cr])
     assert cells.ranges == [cr]
コード例 #10
0
 def test_check_title(self, CellRange, r1, r2, expected):
     cr1 = CellRange(r1)
     cr2 = CellRange(r2)
     assert cr1._check_title(cr2) is expected
コード例 #11
0
 def test_different_worksheets(self, CellRange, r1, r2):
     cr1 = CellRange(r1)
     cr2 = CellRange(r2)
     with pytest.raises(ValueError):
         cr1._check_title(cr2)
コード例 #12
0
 def test_doesnt_contain(self, CellRange):
     cr = CellRange("A1:F10")
     assert not "M1" in cr
コード例 #13
0
 def test_ctor(self, CellRange):
     cr = CellRange(min_col=1, min_row=1, max_col=5, max_row=7)
     assert (cr.min_col, cr.min_row, cr.max_col, cr.max_row) == (1, 1, 5, 7)
     assert cr.coord == "A1:E7"
コード例 #14
0
 def test_contains(self, CellRange):
     cr = CellRange("A1:F10")
     assert "B3" in cr
コード例 #15
0
 def test_from_string(self, CellRange, range_string, title, coord):
     cr = CellRange(range_string)
     assert cr.coord == coord
     assert cr.title == title
コード例 #16
0
 def test_from_string(self, MultiCellRange, CellRange):
     cells = MultiCellRange("A1 B2:B5")
     assert cells.ranges == [CellRange("A1"), CellRange("B2:B5")]
コード例 #17
0
 def test_repr(self, CellRange):
     cr = CellRange("Sheet1!$A$1:B4")
     assert repr(cr) == "<CellRange 'Sheet1'!A1:B4>"
コード例 #18
0
 def test_max_row_too_small(self, CellRange):
     with pytest.raises(ValueError):
         cr = CellRange("A4:B1")
コード例 #19
0
 def test_eq(self, CellRange):
     cr1 = CellRange("'Sheet 1'!$A$1:B4")
     cr2 = CellRange("'Sheet 1'!$A$1:B4")
     assert cr1 == cr2
コード例 #20
0
 def test_add(self, MultiCellRange, CellRange):
     cr = CellRange("A1")
     cells = MultiCellRange(ranges=[cr])
     cells += "B2"
     assert cells.ranges == [cr, CellRange("B2")]
コード例 #21
0
 def test_copy(self, CellRange):
     cr1 = CellRange("Sheet1!$A$1:B4")
     cr2 = copy(cr1)
     assert cr2 is not cr1
コード例 #22
0
 def test_repr(self, MultiCellRange, CellRange):
     cr1 = CellRange("a1")
     cr2 = CellRange("B2")
     cells = MultiCellRange(ranges=[cr1, cr2])
     assert repr(cells) == "<MultiCellRange [A1 B2]>"
コード例 #23
0
 def test_shift_negative(self, CellRange):
     cr = CellRange("A1:B4")
     with pytest.raises(ValueError):
         cr.shift(-1, 2)
コード例 #24
0
 def test_contains(self, MultiCellRange, CellRange):
     cr = CellRange("A1:E4")
     cells = MultiCellRange([cr])
     assert "C3" in cells
コード例 #25
0
 def test_no_union(self, CellRange):
     cr1 = CellRange("Sheet1!A1:D4")
     cr2 = CellRange("Sheet2!E5:K10")
     with pytest.raises(ValueError):
         cr3 = cr1.union(cr2)
コード例 #26
0
 def test_max_col_too_small(self, CellRange):
     with pytest.raises(ValueError):
         cr = CellRange("F1:B5")
コード例 #27
0
 def test_shrink(self, CellRange):
     cr = CellRange("E5:K10")
     cr.shrink(right=2, bottom=2, left=1, top=2)
     assert cr.coord == "F7:I8"
コード例 #28
0
 def test_iter(self, MultiCellRange, CellRange):
     cells = MultiCellRange("A1")
     assert list(cells) == [CellRange("A1")]
コード例 #29
0
 def test_intersection(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("D2:F7")
     cr3 = cr1.intersection(cr2)
     assert cr3.coord == "E5:F7"
コード例 #30
0
 def test_issuperset(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("F6:J8")
     assert cr1.issuperset(cr2) is True