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'"
def test_slice_too_many(): with pytest.raises(ValueError) as exc: _slice('2,2,2') assert str(exc.value) == 'too many slice parts'
def test_slice_empty(): with pytest.raises(ValueError) as exc: assert _slice('') assert str(exc.value) == "invalid literal for int() with base 10: ''"
def test_slice_simple(): assert _slice('2') == (2, None) assert _slice('2,2') == (2, 2)
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')
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:")
def test_slice_simple(self): self.assertEqual(_slice('2'), (2, None)) self.assertEqual(_slice('2,2'), (2, 2))