I am working on a project in Python, using Git for version control, and I've decided it's time to add a couple of unit tests. However, I'm not sure about the best way to go about this.
I have two main questions: which framework should I use and how should I arrange my tests? For the first, I'm planning to use unittest since it is built in to Python, but if there is a compelling reason to prefer something else I'm open to suggestions. The second is a tougher question, because my code is already somewhat disorganized, with lots of submodules and relative imports. I'm not sure where to fit the testing code. Also, I'd prefer to keep the testing code seperate from everything else if possible. Lastly, I want the tests to be easy to run, preferably with a single commandline command and minimal path setup. 
How do large Python projects handle testing? I understand that there is typically an automated system to run tests on all new checkins. How do they do it? What are the best practices for setting up a testing system?
The Python unittest is fine, but it may be difficult to add unit testing to a large project. The reason is that unit testing is related to the testing of the functionality of the tiniest blocks.
Unit testing means to use a lot of small tests that are separated each from the other. They should be independent on anything but the tested part of the code.
When unittests are added to the existing code, it is usually added only to test the isolated cases that was proved to cause the error. The added unittest should be written with uncorrected functionality to disclose the error. Then the error should be fixed so that the unittest passes. This is the first extreme -- to add unit tests only to the code that fails. This is a must. You should always add unit test for the code that fails, and you should do it before you fix the error.
Now, it is a question how to add unit tests to the large project that did not use them. The quantity of code of unit tests may be comparable with the size of the project itself. This way the other extreme could be to add unit test to everything. However, this is too much work, and you usually have to reverse engineer your own code to find the building blocks to be tested.
I suggest to find the most important parts of the code and add unit tests to them.
How to arrange and set up unit testing in Python