inertia-django icon indicating copy to clipboard operation
inertia-django copied to clipboard

Setup method not working while testing

Open pvpmartins opened this issue 1 year ago • 1 comments

So, I would like to use the very handy setup method in order to make some test cases without repeating myself.

class RegisterViewTest(InertiaTestCase):
    def setUp(self):
        # Setup run before every test method.
        self.test_user = User.objects.create_user(username='testuser', password='testpassword')

But unfortunately i get this error:

Traceback (most recent call last):
  File "/home/pvpmartins/nutrify/myenv/lib/python3.11/site-packages/inertia/test.py", line 25, in tearDown
    self.mock_inertia.stop()
    ^^^^^^^^^^^^^^^^^
AttributeError: 'RegisterViewTest' object has no attribute 'mock_inertia'

======================================================================
ERROR: test_register_and_login_pro_user (nutrifyapp.tests.RegisterViewTest.test_register_and_login_pro_user)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pvpmartins/nutrify/myenv/lib/python3.11/site-packages/inertia/test.py", line 25, in tearDown
    self.mock_inertia.stop()
    ^^^^^^^^^^^^^^^^^
AttributeError: 'RegisterViewTest' object has no attribute 'mock_inertia'

pvpmartins avatar Feb 10 '24 00:02 pvpmartins

Hi I'm also facing this error. Were you able to solve it?

Edit: I was able to solve it like by calling InertiaTestCase.setUp(self) in the setUp method like so

def setUp(self):
    InertiaTestCase.setUp(self)

CalElAn avatar Aug 11 '24 20:08 CalElAn