Skip to content

Project Structure

Antonio Antunes edited this page Mar 3, 2020 · 2 revisions

Based on article ultimate-setup-for-your-next-python-project

Let’s outline what we have here, starting from the top:

  • blueprint - This is our source code directory, which should be named by your application or package you are working on. Inside we have the usual init.py file signifying that it's a Python package, next there is main.py which is used when we want to run our application directly with python -m blueprint. Last source file here is the app.py which is here really just for demonstration purposes. In real project instead of this app.py you would have few top level source files and more directories (internal packages). We will get to contents of these files a little later. Finally, we also have resources directory here, which is used for any static content your application might need, e.g. images, keystore, etc.

  • tests - In this directory resides our test suite. I'm not gonna go into too much detail here as we will dedicate whole section to testing, but just briefly:

  1. test_app.py is a test file corresponding to app.py in source directory
  2. conftest.py is probably familiar to you if you ever used Pytest - it's a file used for specifying Pytest fixtures, hooks or loading external plugins.
  3. context.py helps with imports of source code files from blueprint directory by manipulating class path. We will see how that works in sec.
Clone this wiki locally