Search code examples
pythonunit-testingcommentsmultiline

commenting out python code including comments in it


Imagine this situation.

I am unittesting a piece of code and in order to do that I passed a multiline string to a class. I have several methods to test:

def testMyClassmethod2(self):
   print('\n>>Start 2')
   comment= '\n two references no brakets\n'
        
   desc = '''This is a multiline text
        including another line,
        and yet another'''

Now imagine I have 20 methods. I made a buch of changes and when I run the unittest I get a bunch of errors. I would like to go one by one looking at what is going on. (Yes, it might not be the best design approach, the unittests should passed) In any case I would like to comment out all the methods from method 1 on. OK, my idea was using ''' before method 2 and ''' at the end before if name='main', but this does not work since every method containes a multiline string already using ''' x x x '''.

How do you proceed? Is there a way to include also those strings in a commented out code?

NOTE: I am working in VS code


Solution

  • I am working with a swiss keyboard

    CTRL + / (but in numpad keys) does the job.

    in a swiss keyboard using "/" as in MAYS+7 does not work.