Exemplo n.º 1
0
 def test_is_not_superset(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("A1:D4")
     assert cr1.issuperset(cr2) is False
Exemplo n.º 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"
Exemplo n.º 3
0
 def test_size(self, CellRange):
     cr = CellRange("E5:K10")
     assert cr.size == {'columns': 7, 'rows': 6}
Exemplo n.º 4
0
 def test_shift(self, CellRange):
     cr = CellRange("A1:B4")
     cr.shift(1, 2)
     assert cr.coord == "B3:C6"
Exemplo n.º 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)
Exemplo n.º 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"
Exemplo n.º 7
0
 def test_ne(self, CellRange):
     cr1 = CellRange("'Sheet 1'!$A$1:B4")
     cr2 = CellRange("Sheet1!$A$1:B4")
     assert cr1 != cr2
Exemplo n.º 8
0
 def test_gt(self, CellRange):
     cr1 = CellRange("A1:F5")
     cr2 = CellRange("A2:F4")
     assert cr1 > cr2
Exemplo n.º 9
0
 def test_ctor(self, MultiCellRange, CellRange):
     cr = CellRange("A1")
     cells = MultiCellRange(ranges=[cr])
     assert cells.ranges == [cr]
Exemplo n.º 10
0
 def test_check_title(self, CellRange, r1, r2, expected):
     cr1 = CellRange(r1)
     cr2 = CellRange(r2)
     assert cr1._check_title(cr2) is expected
Exemplo n.º 11
0
 def test_different_worksheets(self, CellRange, r1, r2):
     cr1 = CellRange(r1)
     cr2 = CellRange(r2)
     with pytest.raises(ValueError):
         cr1._check_title(cr2)
Exemplo n.º 12
0
 def test_doesnt_contain(self, CellRange):
     cr = CellRange("A1:F10")
     assert not "M1" in cr
Exemplo n.º 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"
Exemplo n.º 14
0
 def test_contains(self, CellRange):
     cr = CellRange("A1:F10")
     assert "B3" in cr
Exemplo n.º 15
0
 def test_from_string(self, CellRange, range_string, title, coord):
     cr = CellRange(range_string)
     assert cr.coord == coord
     assert cr.title == title
Exemplo n.º 16
0
 def test_from_string(self, MultiCellRange, CellRange):
     cells = MultiCellRange("A1 B2:B5")
     assert cells.ranges == [CellRange("A1"), CellRange("B2:B5")]
Exemplo n.º 17
0
 def test_repr(self, CellRange):
     cr = CellRange("Sheet1!$A$1:B4")
     assert repr(cr) == "<CellRange 'Sheet1'!A1:B4>"
Exemplo n.º 18
0
 def test_max_row_too_small(self, CellRange):
     with pytest.raises(ValueError):
         cr = CellRange("A4:B1")
Exemplo n.º 19
0
 def test_eq(self, CellRange):
     cr1 = CellRange("'Sheet 1'!$A$1:B4")
     cr2 = CellRange("'Sheet 1'!$A$1:B4")
     assert cr1 == cr2
Exemplo n.º 20
0
 def test_add(self, MultiCellRange, CellRange):
     cr = CellRange("A1")
     cells = MultiCellRange(ranges=[cr])
     cells += "B2"
     assert cells.ranges == [cr, CellRange("B2")]
Exemplo n.º 21
0
 def test_copy(self, CellRange):
     cr1 = CellRange("Sheet1!$A$1:B4")
     cr2 = copy(cr1)
     assert cr2 is not cr1
Exemplo n.º 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]>"
Exemplo n.º 23
0
 def test_shift_negative(self, CellRange):
     cr = CellRange("A1:B4")
     with pytest.raises(ValueError):
         cr.shift(-1, 2)
Exemplo n.º 24
0
 def test_contains(self, MultiCellRange, CellRange):
     cr = CellRange("A1:E4")
     cells = MultiCellRange([cr])
     assert "C3" in cells
Exemplo n.º 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)
Exemplo n.º 26
0
 def test_max_col_too_small(self, CellRange):
     with pytest.raises(ValueError):
         cr = CellRange("F1:B5")
Exemplo n.º 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"
Exemplo n.º 28
0
 def test_iter(self, MultiCellRange, CellRange):
     cells = MultiCellRange("A1")
     assert list(cells) == [CellRange("A1")]
Exemplo n.º 29
0
 def test_intersection(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("D2:F7")
     cr3 = cr1.intersection(cr2)
     assert cr3.coord == "E5:F7"
Exemplo n.º 30
0
 def test_issuperset(self, CellRange):
     cr1 = CellRange("E5:K10")
     cr2 = CellRange("F6:J8")
     assert cr1.issuperset(cr2) is True