pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.64k stars 2.59k forks source link

(fixtures): Replace fixture represenation with a class #12473

Open Glyphack opened 2 weeks ago

Glyphack commented 2 weeks ago

Closes #11525

During the sprint we discussed fixing the above issue and thought maybe it's a better idea to add a better represenation to fixtures. To do this without patching the object more, this PR refactors fixtures to have a class with attributes. The main rational behind that is:

Example

Previously we had:

===================================== short test summary info ======================================
FAILED tmp31nzhe4b.py::test_something - assert fixt == 42
======================================== 1 failed in 0.03s =========================================

where fixt is a pytest fixture function that is not replaced by it's value(directly used)

Now we print:

===================================== short test summary info ======================================
FAILED tmp31nzhe4b.py::test_something - assert pytest_fixture(<function fixt at *>) == 42 
======================================== 1 failed in 0.03s =========================================
Glyphack commented 4 days ago

Hey @The-Compiler @RonnyPfannschmidt I rebased the PR could you please take a look?