0

I am having below code

def test_8_match(self):
                    logging.info("--------------------------------------------------------------------------------------")
        logging.info("Testcase 1: start")
        start = datetime.datetime.now(utc)
        print start
        self.assertEqual(Val1, Val2)

I am trying to override assertEqual function just to add some extra stuff

 def assertEqual(self, first, second, msg=None):
        if first == second :
            logging.info("Both value are equal", first , second)
            return True
        else :
            logging.info("Both value are not equal", first, second)

            return False

It is not working. It is still calling original proc

Another Query: In this unittest framework, print statements are not coming. is there any way I can use print statements in this code ?

Sumit
  • 1,953
  • 6
  • 32
  • 58
  • Where are you attempting to override assertEqual? – bouteillebleu Nov 24 '17 at 11:02
  • In the same class where I am calling – Sumit Nov 24 '17 at 11:03
  • 1
    About the second query - unittest usually captures printed output, and only shows it if a test failed. But if you need to check what was output, you can use one of the methods suggested in https://stackoverflow.com/questions/4219717/how-to-assert-output-with-nosetest-unittest-in-python to redirect stdout to a StringIO object and then test its contents. – bouteillebleu Nov 24 '17 at 11:04
  • Thanks but what about the first query – Sumit Nov 24 '17 at 11:06

0 Answers0