Skip to content

Commit

Permalink
[pickle] Skip invalid input tests (#8)
Browse files Browse the repository at this point in the history
* [TESTS] Skip invalid pickle data tests

* [UPDATE] Replaced os.urandom() by random.randbytes() for reproducible tests
  • Loading branch information
francis-clairicia committed Mar 18, 2023
1 parent 887206d commit 7eb65b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/functional_test/test_serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

import os
import random
from abc import ABCMeta
from typing import Any, Callable, final

Expand All @@ -25,7 +25,7 @@ def oneshot_extra_data() -> bytes:
@pytest.fixture(scope="class")
@staticmethod
def invalid_complete_data() -> bytes:
return os.urandom(32)
return random.randbytes(32)

def test____fixture____consistency(
self,
Expand Down Expand Up @@ -119,7 +119,7 @@ def incremental_extra_data() -> bytes:
@pytest.fixture(scope="class")
@staticmethod
def invalid_partial_data() -> bytes:
return os.urandom(32)
return random.randbytes(32)

@pytest.fixture(scope="class")
@staticmethod
Expand Down
10 changes: 10 additions & 0 deletions tests/functional_test/test_serializers/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ def complete_data_for_incremental_deserialize(complete_data: bytes) -> bytes:

#### Invalid data

@pytest.fixture
@staticmethod
def invalid_complete_data() -> bytes:
pytest.skip("pickle.Unpickler() raises SystemError for some invalid inputs :)")

@pytest.fixture
@staticmethod
def invalid_partial_data() -> bytes:
pytest.skip("pickle.Unpickler() raises SystemError for some invalid inputs :)")

@pytest.fixture(scope="class")
@staticmethod
def invalid_partial_data_extra_data() -> bytes | None:
Expand Down

0 comments on commit 7eb65b2

Please sign in to comment.