Update to Python

If you run into issues running Python unit tests with Tox after enabling the logging, you may have to add some additional code not covered in the video. See this page: Example 5 Python Updates

Resources

Configuring Codio Debugger

Python Python

Python 2 Python 2

Edit src/__main__.py to set Python path:

import sys
sys.path.append("/home/codio/workspace/python/")

Make sure src/__main__.py imports and calls correct main method.

Can copy unit test code to a test main function for testing. Codio doesn’t have a good way to individually debug a single unit test, but some IDEs do.

Tox Changes

In the tox.ini file, we added the following line under the [testenv] heading:

ignore_errors = True

This will allow the full Tox script to execute, even if there are errors earlier in the process.

We also removed the line to generate documentation, as it is not needed.

Outline

Here is a basic outline of the steps to follow to complete this example.

  1. Clone Starter Code from GitHub
git clone <url> python
  1. Run Project
cd python
python3 -m src
  1. Install Tox
pip3 install tox
  1. Check & Test Existing Project
python3 -m tox
  1. Confirm that project runs, no style errors, and tests execute (some tests will fail).

  2. Fix Code to Pass Unit Tests. Use Codio debugger and/or Logging

  3. Add logging to both files

  4. Add README.md and discuss how you solved the errors.

  5. Confirm that project runs and all tests pass.

  6. When complete, use Git to commit and push updated code.

git add .
git commit -m "Example Complete"
git push
  1. On GitHub, create a release tag and submit URL to Canvas for grading.