ktosiek / pytest-vcr

Py.test integration with VCR.py
MIT License
154 stars 25 forks source link

fix - regression on handling the cassette name in a class that inherits from unittest.TestCase #20

Closed arthurHamon2 closed 5 years ago

arthurHamon2 commented 5 years ago

A weird thing happens with pytest 4.X.X when using vcr on a "unittest.TestCase" class, the cassette name do not have the class name anymore compared with pytest 3.X.X.

The cassette name did not include the class name if it inherits from unittest.TestCase, use the attribute "request.cls" to get the class instead of relying on hasattr(request.function, 'self').

ktosiek commented 5 years ago

Thank you for looking into this, and sorry for not replying earlier. I'll try to test those changes over the weekend.

wt., 16 kwi 2019, 07:27 użytkownik Arthur Hamon notifications@github.com napisał:

A weird thing happens with pytest 4.X.X when using vcr on a "unittest.TestCase" class, the cassette name do not have the class name anymore compared with pytest 3.X.X.

The cassette name did not include the class name if it inherits from unittest.TestCase, use the attribute "request.cls" to get the class instead of relying on hasattr(request.function, 'self').

You can view, comment on, or merge this pull request online at:

https://github.com/ktosiek/pytest-vcr/pull/20 Commit Summary

  • fix - regression on handling the cassette name in a class that inherits from unittest.TestCase

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ktosiek/pytest-vcr/pull/20, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ9_WfBovdNZb66PHn28u24F5ftKDDUks5vhV85gaJpZM4cxYwr .

arthurHamon2 commented 5 years ago

No worries, this is a very specific case where we are moving from setUp/tearDown pattern to pytest with fixtures. Sometimes we end up using vcrpy in a old unittest.TestCase (which is bad). At the moment we override the fixture "vcr_cassette_name" to take care of this issue, but I guess this fix would help the community if someone encounters the same issue. Thank you for your response and your time, really appreciated !