Skip to content

Tests are not generated when input parameters are not serializable by pickle #1845

Open
@tochilinak

Description

@tochilinak

Description

Some Python types (for example, socket or Logger) are not serializable by pickle, but we can still create them with constructors. Now test generation for such types fail.

To Reproduce

Steps to reproduce the behavior:

  1. Create project with Python code:
from logging import Logger

def f(x: Logger):
    return x.name
  1. Use plugin to generate tests

Expected behavior

Tests are supposed to be generated.

Actual behavior

Tests were not generated.

Visual proofs (screenshots, logs, images)

When test generation is run by CLI with --verbosity=DEBUG key, these exceptions are shown:

13:16:30.001 | DEBUG | PythonEngine | Traceback (most recent call last):
  File "/tmp/UTBot/python-test-generation-017837888855378174660/tmp_18_run_f.py", line 14, in <module>
    __utbot_executor.run_calculate_function_value(r'/tmp/UTBot/python-test-generation-017837888855378174660/tmp_17_coverage_db_f',
  File "/home/tochilinak/.local/lib/python3.10/site-packages/utbot_executor/executor.py", line 41, in run_calculate_function_value
    _, _, _, state_before = serialize_state(args, kwargs)
  File "/home/tochilinak/.local/lib/python3.10/site-packages/utbot_executor/executor.py", line 24, in serialize_state
    ids, serialized_memory = serialize_objects(all_arguments)
  File "/home/tochilinak/.local/lib/python3.10/site-packages/deep_serialization/deep_serialization.py", line 26, in serialize_objects
    ids = [
  File "/home/tochilinak/.local/lib/python3.10/site-packages/deep_serialization/deep_serialization.py", line 27, in <listcomp>
    serializer.write_object_to_memory(obj)
  File "/home/tochilinak/.local/lib/python3.10/site-packages/deep_serialization/memory_objects.py", line 224, in write_object_to_memory
    serializer = provider.get_serializer(py_object)
  File "/home/tochilinak/.local/lib/python3.10/site-packages/deep_serialization/memory_objects.py", line 177, in get_serializer
    if has_reduce(obj):
  File "/home/tochilinak/.local/lib/python3.10/site-packages/deep_serialization/utils.py", line 33, in has_reduce
    py_object.__reduce__()
  File "/usr/lib/python3.10/logging/__init__.py", line 1774, in __reduce__
    raise pickle.PicklingError('logger cannot be pickled')
_pickle.PicklingError: logger cannot be pickled

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a buglang-pythonIssue is related to python support

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions