unit testing - How should I organize Python source code? -


My first project is a queue that runs a command line experiment in multiple threads. I am starting to get a very long main.py file, and I want to break it. In general, I'm looking for: How do Python programmers organize multiple source files? Is there any special structure that works for you?

My specific questions include:

  • Should each class be in a different file?
  • How can I organize unit tests relative to source code?
  • Where should I place a doctor's remark, especially for command-line operations?
  • If I use multiple directories, how do I import clients between them? Perhaps I can draw some conclusions here by testing and error, but instead of good

  • P>

    It's great for something that you want to start with because it contains details of organizing large python code base.

    If you come here from Google and are trying to figure out how to split a large source file into multiple, more manageable files, I will briefly summarize the process.

    Assume that you currently have everything in a fi, called main.py :

    • another in the same folder Create source file (for this example we call our utils.py )
    • In the main code Add a line at the top: import utils

    What it does conceptually is to create a new module called utils another In the source file. You can still import it where it is necessary.


    Comments

    Popular posts from this blog

    c# - How to capture HTTP packet with SharpPcap -

    php - Multiple Select with Explode: only returns the word "Array" -

    php - jQuery AJAX Post not working -