test: Add unit test for pydumpling/fake_types.py
Trigger Info
| Trigger Type | Triggered By | Source File | Assignment |
|---|---|---|---|
| Manual | cocolato | pydumpling/fake_types.py | Detail |
Summary
This PR introduces a comprehensive suite of unit tests for the FakeType, FakeTraceback, FakeFrame, FakeClass, and FakeCode classes in the pydumpling.fake_types module. The tests ensure the correctness of the functionality and behavior of these classes, including their initialization, attribute handling, and utility methods.
Key Changes:
-
Test Coverage for
FakeTraceback:-
Tests for initialization with and without a mock traceback object.
-
Validation of attributes like
tb_frame,tb_lineno,tb_next, andtb_lasti.
-
-
Test Coverage for
FakeFrame:-
Tests for initialization with a mock frame object.
-
Validation of attributes like
f_code,f_globals,f_lineno,f_back,f_lasti, andf_builtins.
-
-
Test Coverage for
FakeCode:-
Tests for initialization with a mock code object.
-
Validation of attributes like
co_filename,co_name,co_argcount,co_consts,co_firstlineno,co_lnotab,co_varnames,co_flags, andco_code. -
Tests for handling
co_lines,co_kwonlyargcount, andco_positions.
-
-
Utility Method Tests:
-
_safe_repr: Ensures safe handling of objects that raise exceptions in their__repr__method. -
_convert: Tests for converting various types of objects, including sequences and dictionaries. -
_convert_dict: Tests for converting dictionaries with simple and complex keys.
-
Fixtures:
- Added reusable pytest fixtures for mock traceback, frame, and code objects to streamline test setup.
These tests enhance the reliability of the pydumpling.fake_types module by verifying its behavior under various scenarios and edge cases.
[!TIP] You can
@gru-agentand leave your feedback. TestGru will make adjustments based on your input
[!TIP] You can
@gru-agent rebaseto rebase the PR.
[!TIP] You can
@gru-agent redoto reset or rebase before redoing the PR.
[!TIP] To modify the test code yourself, click here Edit Test Code