1

I have the following unit test written in python,When i try to run this code, i am getting an attribute error in the console that AttributeError: 'testLogin' object has no attribute 'lp' I am very new to python and i would like to get some insight on this attribute issue

Is there any issues that needs to be fixed. Your help us highly recommended.

from utilities.teststatus import TestStatus as ts
import unittest
import pytest

@pytest.mark.usefixtures("oneTimeSetup", "setUp")
class testLogin(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def classSetup(self,oneTimeSetup):
        self.lp = LoginPage(self.driver)
    @pytest.mark.order1
    def test_validLogin(self):
        self.lp.login("test@email.com", "abcabc")
        userIcon = self.lp.verifyLoginSuccessful()
        title = self.lp.verifyPageTitle()
        ts.markFinal(title,"Login not successful")
        assert userIcon == True

When i try to run this unittest, i am getting the error as AttributeError: 'testLogin' object has no attribute 'lp'

Can some one please help to fix it ?

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
  • Looks like `classSetup` is not run for some reason. Maybe you are running `unittest` instead of `pytest`? You shouldn't mix pytest and unittest - there is no reason to derive from `unittest.TestCase` if you are using `pytest` (even if it would work), and `unittest` knows nothing about `pytest`. – MrBean Bremen May 18 '20 at 18:52
  • Thanks.. That helped. I was running the tests as unitTests. Now i changed the configurations to Pytest and it runs.. Thanks – user3811770 Jun 04 '20 at 09:56

0 Answers0