Corresponding file hierarchy for unittesting in Python

I am developing a collection of Python packages / modules (no executables). What is the right / best way to set up a file hierarchy for testing. I can imagine two scenarios:

Scenario 1:

AllPackages/
    package1/
        module1-1.py
        module1-2.py
    package2/
        module2-1.py
        module2-2.py
    tests/
        package1/
            test_module1-1.py
            test_module1-2.py
        package2/
            test_module2-1.py
            test_module2-2.py

Scenario 2:

AllPackages/
    package1/
        module1-1.py
        module1-2.py
        tests/
            test_module1-1.py
            test_module1-2.py
    package2/
        module2-1.py
        module2-2.py
        tests/
            test_module2-1.py
            test_module2-2.py

I am new to unittesting (I know I should have done this for a long time), so I'm not sure which of these approaches is better, and I'm looking for advice from those with more experience.

Thank!

+5
source share
2 answers

Django ( ). unittest, discover, , , , , .

+1

1 , . , , . , tests/ . .

2 ; .

+1

All Articles