Python - What's the proper way to unittest methods in a different class? <p>I've written a module called Consumer.py, containing a class (Consumer). This class is initialized using a configuration file thay contains different parameters it uses for computation and the name of a loq que used for logging.</p> <p>I want to write unit tests for this class so i've made a script called test_Consumer.py with a class called TestConsumerMethods(unittest.TestCase).</p> <p>Now, what i've done is create a new object of the Consumer class called cons, and then i use that to call on the class methods for testing. For example, Consumer has a simple method that checks if a file exists in a given directory. The test i've made looks like this</p> <pre><code>import Consumer from Consumer import Consumer cons = Consumer('mockconfig.config', 'logque1') class TestConsumerMethods(unittest.TestCase): def test_fileExists(self): self.assertEqual(cons.file_exists('./dir/', 'thisDoesntExist.config), False) self. assertEqual(cons.file_exists('./dir/', thisDoesExist.config), True) </code></pre> <p>Is this the correct way to test my class? I mean, ideally i'd like to just use the class methods without having to instantiate the class because to "isolate" the code, right?</p>