title: Python 3 - doctest module for long .txt files
body: <p>I have a quick question regarding the doctest module in Python 3.</p>
  <p>I haven't used it yet, just read some information and how they apply it to functions. I have two functions I need to test and I think I understand what I have to do. However, I have no clue how to apply it in my case. I have to functions that work with .txt files. The first one takes a word and the file
  path to a text file as input and outputsa list of pairs, each consisting of a
  line in which the word occurs and the corresponding line number.</p>
  <pre><code>def find_all_instances(word, path):
      l = []
      with open(path, 'r') as file:
          for position, line in enumerate(file.readlines()):
              if word in line:
                  tup = (line, position+1)
                  l.append(tup)
          return l
  print(find_all_instances('word', 'filename.txt'))
  </code></pre>
  <p>The second function takes the file path to a text file as input and outputs a
  list of pairs, each consisting of a word and the number of times the word occurs
  in the text in decreasing order.</p>
  <pre><code>from collections import Counter
  import re
  
  def task_2(inp):
      with open(inp, encoding=&quot;utf-8&quot;) as f:
          data = (x.lower() for x in re.split(r'[\n, .?!:;-]', f.read()) if x.isalpha())
      cnt = Counter(data)
      return cnt.most_common()
  
  task_2(r&quot;filepath&quot;)
  </code></pre>
  <p>My question now is: How can I apply this in these cases? Since the examples of doctest that I've seen only use simple functions that for example multiply two inputs. However, in my cases, the output seems to be quite large since the text files are about 10'000 lines long and therefore the output is equally large. How can one implement it for these functions?</p>