import doctest
def create_grid(size):
   grid = []
   for i in range(size):
       row = ['0']*size
       grid.append(row)
   """
   >>> create_grid(4)
   [['0', '0', '0', '0'], ['0', '0', '0', '0'],
    ['0', '0', '0', '0'], ['0', '0', '0', '0']]
   """
   return grid
if __name__ == '__main__':
    doctest.testmod()
Running the above with python Test_av_doctest.py -v gives the following message:
2 items had no tests:
    __main__
    __main__.create_grid
0 tests in 2 items.
0 passed and 0 failed.
Test passed.
Any idea why this error occurs?
The issue is that your doctest-formatted string isn't a docstring.
Which docstrings are examined?
The module docstring, and all function, class and method docstrings are searched.
If you move the testing string below the function definition, it will become a function docstring, and thus will be targeted by doctest:
def create_grid(size):
   """
   >>> create_grid(4)
   [['0', '0', '0', '0'], ['0', '0', '0', '0'],
    ['0', '0', '0', '0'], ['0', '0', '0', '0']]
   """
   grid = []
   for i in range(size):
       row = ['0']*size
       grid.append(row)
   return grid
if __name__ == '__main__':
    doctest.testmod()
$ python Test_av_doctest.py -v
...
1 passed and 0 failed.
Test passed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With