Exemple #1
0
def test_getColumnLetterOf():
    assert ezsheets.getColumnLetterOf(1) == 'A'
    assert ezsheets.getColumnLetterOf(26) == 'Z'
    assert ezsheets.getColumnLetterOf(27) == 'AA'
    assert ezsheets.getColumnLetterOf(702) == 'ZZ'

    with pytest.raises(TypeError):
        ezsheets.getColumnLetterOf('invalid arg')

    with pytest.raises(ValueError):
        ezsheets.getColumnLetterOf(0)

    with pytest.raises(ValueError):
        ezsheets.getColumnLetterOf(-1)
Exemple #2
0
def test_convertToColumnRowInts():
    assert ezsheets.convertToColumnRowInts('A1') == (1, 1)
    assert ezsheets.convertToColumnRowInts('Z1') == (26, 1)
    assert ezsheets.convertToColumnRowInts('AA1') == (27, 1)
    assert ezsheets.convertToColumnRowInts('ZZ1') == (702, 1)

    assert ezsheets.convertToColumnRowInts('A10') == (1, 10)
    assert ezsheets.convertToColumnRowInts('ZZ10') == (702, 10)

    for i in range(1, 1000):
        for j in range(101):
            assert ezsheets.convertToColumnRowInts(
                ezsheets.getColumnLetterOf(i) + str(j)) == (i, j)

    with pytest.raises(ValueError):
        ezsheets.convertToColumnRowInts('1')
    with pytest.raises(ValueError):
        ezsheets.convertToColumnRowInts('A')
    with pytest.raises(ValueError):
        ezsheets.convertToColumnRowInts('')

    with pytest.raises(TypeError):
        ezsheets.convertToColumnRowInts(123)
Exemple #3
0
import ezsheets

print(ezsheets.convertAddress('A2'))  # Converts addresses... (1, 2)
print(ezsheets.convertAddress(1, 2))  # ...and converts them back, too.'A2'
print(ezsheets.getColumnLetterOf(2))  # 'B'
print(ezsheets.getColumnNumberOf('B'))  # 2
print(ezsheets.getColumnLetterOf(999))  # 'ALK'
print(ezsheets.getColumnNumberOf('ZZZ'))  # 18278
Exemple #4
0
def test_columnNumberLetterTranslation():
    for i in range(1, 5000):
        assert ezsheets.getColumnNumberOf(ezsheets.getColumnLetterOf(i)) == i
import ezsheets
ezsheets.convertAddress('A2')  # Converts addresses...

ezsheets.convertAddress(1, 2)  # ...and converts them back, too.

ezsheets.getColumnLetterOf(2)

ezsheets.getColumnNumberOf('B')
ezsheets.getColumnLetterOf(999)
ezsheets.getColumnNumberOf('ZZZ')