Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup method not working while testing #41

Open
pvpmartins opened this issue Feb 10, 2024 · 1 comment
Open

Setup method not working while testing #41

pvpmartins opened this issue Feb 10, 2024 · 1 comment

Comments

@pvpmartins
Copy link

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'

@CalElAn
Copy link

CalElAn commented Aug 11, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants