title: How to enable custom test discovery with unittest while using xmlrunner
body: <p>Im trying to use custom test discovery while using xmlrunner to report my test results in XML format. Could someone kindly explain to me how I can use <code>unittest.TestLoader().discover()</code> properly? Ive tried the following at the end of file <code>test.py</code>:</p>
  
  <pre><code>if __name__ == '__main__':
       with open('output.xml', 'wb') as output:
           unittest.main(
               testRunner=xmlrunner.XMLTestRunner(output=output),
               failfast=False, buffer=False, catchbreak=False, exit=False, 
               testLoader=unittest.TestLoader().discover('.', pattern = "*_test.py")
           )
  </code></pre>
  
  <p>But this gives the error:</p>
  
  <pre><code>File "test.py", line 20, in &lt;module&gt;
      failfast=False, buffer=False, catchbreak=False, exit=False, testLoader=unittest.TestLoader().discover('.', pattern = "*_test.py"))
    File "/usr/lib/python3.5/unittest/main.py", line 93, in __init__
      self.parseArgs(argv)
    File "/usr/lib/python3.5/unittest/main.py", line 140, in parseArgs
      self.createTests()
    File "/usr/lib/python3.5/unittest/main.py", line 144, in createTests
      self.test = self.testLoader.loadTestsFromModule(self.module)
  AttributeError: 'TestSuite' object has no attribute 'loadTestsFromModule'
  </code></pre>
  
  <p>If I run without the testLoader argument and with the module argument set to None, the test discovery runs but with the default settings which is not what I want.</p>
  
  <p>All the answers I've found thus far pertain to the command line such as <code>python –m unittest discover -p "test*.py" ...</code> which is not what I'm looking for. I would appreciate an in-code solution as suggested by the first code snippet.</p>
  
  <p>Thanks</p>