p3t3
p3t3

Reputation: 123

Typical folder structure for a python project with unit and integration tests?

What would be a typical structure and path/import conventions used? Would anyone have a link to a representative python project?

project.scratch/
    project/
        scratch/
            __init__.py
            dostuff.py
            tests/
                unit/
                    test_dostuff.py
                integration/
                    test_integration.py

Upvotes: 8

Views: 6883

Answers (2)

Joshua Howard
Joshua Howard

Reputation: 916

Similar to what you have shown, the typical python project structure is as follows.

├── app_name
    │
    ├── app_name
    │   ├── __init__.py
    │   ├── folder_name
    │   └── etc...
    ├── tests
    │   ├── unit
    │   └── integration
    ├── README.md
    ├── setup.py
    └── requirements.txt

```

This statement is largely due to personal experience, but it is also the structure advocated here.

I have also seen an integration_tests directory as a sibling of the tests directory instead, but I believe that this is much less common.

Contrary to Bhavish Agarwal's answer, I see no mention of integration tests for Django (only integration tests using Django). It seems they decided not to have any.

Upvotes: 5

Bhavish Agarwal
Bhavish Agarwal

Reputation: 673

Since you asked for a typical structure, why look further than (arguably) the most famous python framework: django

Upvotes: -2

Related Questions