@pytest.mark.usefixtures("oneTimeSetUp","setUp")
class BeyondTest(unittest.TestCase):
log = cl.testLogger(logging.INFO)
@pytest.fixture(autouse=True)
def classSetup(self,oneTimeSetUp):
self.ts = TestStatus(self.driver)
self.bmf = BMF(self.driver)
@pytest.mark.run(order=1)
def test_site_to_csv(self):
self.bmf.imagelist()
first_column =[l[4] for l in self.bmf.csvreader]
list_site_to_csv = [item for item in self.bmf.full_list if item not in first_column]
self.log.INFO(list_site_to_csv)
assert len(list_site_to_csv)<=0
So I have a csv with some data that needs to be verified on a site, I first capture data on the site append to a list "self.bmf.full_list", the csv columns are saved in the first_column list, I then compare both list and save the ones missing from csv but are present on site to the list "list_site_to_csv. The assertion is the len(list_site_to_csv)<=0. What I am trying to figure out is how to log.INFO only when an assertion fails? something like
if assert len(list_site_to_csv)<=0:
then self.log.INFO(list_site_to_csv)
anyother suggestion on better way to handle this than a list would also be great
try/exceptblock to catch the exception, log, then raise the exception.