title: Unittest for click module
body: <p>I wrote a simple command line utility that accepts a text file and searches for a given word in it using the click module.</p>
  
  <p><strong>sfind.py</strong></p>
  
  <pre><code>import click
  @click.command()
  @click.option('--name', prompt='Word or string')
  @click.option('--filename', default='file.txt', prompt='file name')
  @click.option('--param', default=1, prompt="Use 1 for save line and 2 for word, default: ")
  def find(name, filename, param):
      """Simple program that find  word or string at text file and put it in new"""
      try:
          with open(filename) as f, open('result.txt', 'w') as f2:
              count = 0
              for line in f:
                  if name in line:
                      if param == 1:
                          f2.write(line + '\n')
                      elif param == 2:
                          f2.write(name + '\n')
                      count += 1
              print("Find: {} sample".format(count))
              return count
      except FileNotFoundError:
          print('WARNING! ' + 'File: ' + filename + ' not found')
  
  
  if __name__ == '__main__':
      find()
  </code></pre>
  
  <p>Now I need to write a test using unittest (using unittest is required).</p>
  
  <p><strong>test_sfind.py</strong></p>
  
  <pre><code>import unittest
  import sfind
  
  class SfindTest(unittest.TestCase):
      def test_sfind(self):
          self.assertEqual(sfind.find(), 4)
  
  
  if __name__ == '__main__' :
      unittest.main()
  </code></pre>
  
  <p>When I run the test:</p>
  
  <pre><code>python -m unittest test_sfind.py
  </code></pre>
  
  <p>I get an error</p>
  
  <blockquote>
    <p>click.exceptions.UsageError: Got unexpected extra argument (test_sfind.py)</p>
  </blockquote>
  
  <p>How can I test this click command?</p>