title: python how to split test files from code into separate directories
body: <p>Below is a fizzbuzz program done TDD using unittest in one file, I run it in the command line using <code>python fizzbuzz.py -v</code>.</p>
  
  <pre><code>import unittest
  
  class FizzBuzz():
      def fizz_buzz(self, number):
          if number % 3 == 0 and number % 5 == 0:
              return 'fizzbuzz'
  
          if number % 3 == 0:
              return 'fizz'
  
          if number % 5 == 0:
              return 'buzz'
  
          return str(number)
  
  class FizzBuzzTests(unittest.TestCase):
  
      def setUp(self):
          self.fb = FizzBuzz()
  
      def test_one_gets_one(self):
          self.assertEqual('1', self.fb.fizz_buzz(1))
  
      def test_three_gets_fizz(self):
          self.assertEqual('fizz', self.fb.fizz_buzz(3))
  
      def test_five_gets_buzz(self):
          self.assertEqual('buzz', self.fb.fizz_buzz(5))
  
      def test_six_gets_fizz(self):
          self.assertEqual('fizz', self.fb.fizz_buzz(6))
  
      def test_fifteen_gets_fizzbuzz(self):
          self.assertEqual('fizzbuzz', self.fb.fizz_buzz(15))
  
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>I decided to split the file, as having the tests separate will read better.</p>
  
  <p>The tree structure is</p>
  
  <pre><code>|-fizzbuzz
     |-app
       - __init__.py
       -fizzbuzz.py
     |-tests
       - __init__.py
       -test_fizzbuzz.py
  </code></pre>
  
  <p>I split the file as below (only showing part of it, one test and passing code)</p>
  
  <pre><code>#fizzbuzz.py
  class FizzBuzz():
      def fizz_buzz(self, number):
          return str(number)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>#test_fizzbuzz.py
  import unittest
  from fizzbuzz import FizzBuzz
  
  class FizzBuzzTests(unittest.TestCase):
  
      def setUp(self):
          self.fb = FizzBuzz()
  
      def test_one_gets_one(self):
          self.assertEqual('1', self.fb.fizz_buzz(1))
  
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>In the fizzbuzz directory, i run tests with <code>python tests/test_fizzbuzz.py</code> which should pass. </p>
  
  <p>But when I comment out the <code>return str(number)</code> or remove it, I still pass. </p>
  
  <p>If I change <code>self.assertEqual('1', self.fb.fizz_buzz(1))</code> to <code>self.assertEqual('12', self.fb.fizz_buzz(1))</code> it is still running the code which is not there.</p>
  
  <p>I deleted all the <code>.pyc</code> files in the test directory and now I get <code>ImportError: No module named fizzbuzz</code> error</p>
  
  <p>If I move the <code>fizzbuzz.py</code> file into the test folder and run <code>python tests/test_fizzbuzz.py</code> the tests pass (this is how I got the .pyc files). But this is not what i want.</p>
  
  <p>Why is this? Have I split this file up wrong? Am I missing extra code or files?</p>
  
  <p>If I have split it up wrongly, what would be the best way to do so?</p>
  
  <p>Any help appreciated, thanks.</p>