| 1 |
import pytest |
| 2 |
import sys |
| 3 |
import lz4.block |
| 4 |
import psutil |
| 5 |
import os |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
_4GB = 0x100000000 |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
@pytest.mark.skipif( |
| 23 |
os.environ.get('TRAVIS') is not None, |
| 24 |
reason='Skipping test on Travis due to insufficient memory' |
| 25 |
) |
| 26 |
@pytest.mark.skipif( |
| 27 |
sys.maxsize < 0xffffffff, |
| 28 |
reason='Py_ssize_t too small for this test' |
| 29 |
) |
| 30 |
@pytest.mark.skipif( |
| 31 |
psutil.virtual_memory().available < _4GB, |
| 32 |
reason='Insufficient system memory for this test' |
| 33 |
) |
| 34 |
def test_huge(): |
| 35 |
try: |
| 36 |
huge = b'\0' * _4GB |
| 37 |
except MemoryError: |
| 38 |
pytest.skip('Insufficient system memory for this test') |
| 39 |
|
| 40 |
with pytest.raises( |
| 41 |
OverflowError, match='Input too large for LZ4 API' |
| 42 |
): |
| 43 |
lz4.block.compress(huge) |
| 44 |
|
| 45 |
with pytest.raises( |
| 46 |
OverflowError, match='Dictionary too large for LZ4 API' |
| 47 |
): |
| 48 |
lz4.block.compress(b'', dict=huge) |
| 49 |
|
| 50 |
with pytest.raises( |
| 51 |
OverflowError, match='Input too large for LZ4 API' |
| 52 |
): |
| 53 |
lz4.block.decompress(huge) |
| 54 |
|
| 55 |
with pytest.raises( |
| 56 |
OverflowError, match='Dictionary too large for LZ4 API' |
| 57 |
): |
| 58 |
lz4.block.decompress(b'', dict=huge) |
| 59 |
|
| 60 |
|
| 61 |
def test_dummy(): |
| 62 |
pass |