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 ?

4
  • Where are you attempting to override assertEqual? Commented Nov 24, 2017 at 11:02
  • In the same class where I am calling Commented Nov 24, 2017 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 stackoverflow.com/questions/4219717/… to redirect stdout to a StringIO object and then test its contents. Commented Nov 24, 2017 at 11:04
  • Thanks but what about the first query Commented Nov 24, 2017 at 11:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.