コード例 #1
0
def test_slice_no_int():
    with pytest.raises(ValueError) as exc:
        _slice('foo,2')
    assert str(exc.value) == "invalid literal for int() with base 10: 'foo'"
コード例 #2
0
def test_slice_too_many():
    with pytest.raises(ValueError) as exc:
        _slice('2,2,2')
    assert str(exc.value) == 'too many slice parts'
コード例 #3
0
def test_slice_empty():
    with pytest.raises(ValueError) as exc:
        assert _slice('')
    assert str(exc.value) == "invalid literal for int() with base 10: ''"
コード例 #4
0
def test_slice_simple():
    assert _slice('2') == (2, None)
    assert _slice('2,2') == (2, 2)
コード例 #5
0
 def test_slice_too_many(self):
     with self.assertRaises(ValueError) as exc:
         _slice('2,2,2')
     self.assertEqual(str(exc.exception.args[0]), 'too many slice parts')
コード例 #6
0
 def test_slice_no_int(self):
     with self.assertRaises(ValueError) as exc:
         _slice('foo,2')
     assert str(exc.exception.args[0]).startswith(
         "invalid literal for int() with base 10:")
コード例 #7
0
 def test_slice_simple(self):
     self.assertEqual(_slice('2'), (2, None))
     self.assertEqual(_slice('2,2'), (2, 2))