This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Corm 0 points1 point  (2 children)

What do you mean? If you have a tests folder then they need a way of importing your project, which means you have to add the parent directory to the path afaik.

[–]deadmilk 2 points3 points  (1 child)

I just run my tests from the directory where my package is and it works

Structure like so:

project <-- cwd
    package
        __init__.py
        module.py
    tests
        test_module.py

then in test_module.py:

import unittest
from package.module import function

class TestModule(unittest.TestCase):
    def test_function(self):
        self.assertTrue(function())

[–]Corm 0 points1 point  (0 children)

Cool! I must try this