Goodies for Instructors!
Goodies for Instructors!
Good discussion of PyTest vs. UnitTest: https://blog.j-labs.pl/2019/02/Pytest-why-its-more-popular-than-unittest
Flake8 Intro on Medium: https://medium.com/python-pandemonium/what-is-flake8-and-why-we-should-use-it-b89bd78073f2
Code Linters: https://github.com/collections/clean-code-linters
Python Running PyTest with Src Directory:
Discussion on src folder for Python: https://hynek.me/articles/testing-packaging/
Running PyTest with Src:
Using main in Python: https://www.geeksforgeeks.org/usage-of-__main__-py-in-python/
Running Coverage: https://coverage.readthedocs.io/en/coverage-5.3/source.html#source
pip3 install pytest
pip3 install pytest-html
python3 -m pytest
python3 -m pytest --html=report.html
pip3 install coverage
python3 -m coverage run --source src -m pytest --html=report.html
python3 -m coverage html
pip3 install flake8
pip3 install pep8-naming
pip3 install flake8-docstrings
pip3 install flake8-html
python3 -m flake8 --docstring-convention google --format=html --htmldir=flake
This page contains notes on deploying this course for a new semester. There are many things to remember to do!
This page is a quick reference for any known errata that have yet to be resolved.
flake8-html plugin has not been updated to work with Flake 8 version 5.0.0.
The bug report is here: https://github.com/lordmauve/flake8-html/issues/30 .
In the meantime, you can fix this by locking
flake8 to a version below 5.0.0 in the
requirements.txt file by updating the entry for
flake8 to the following:
# Lock flake8 to <5.0.0
This error may have been resolved by moving Python to version 3.9 in Fall 2022. It has not been tested yet; this will be updated once it is tested and confirmed working.
In Python, you may get some errors when running Flake8 due to a bug. The error message references the “Markup” class as part of “Jinja2” which is used by the Flake8-html plugin.
The bug report and pull request to fix it is here: https://github.com/lordmauve/flake8-html/pull/24 . It has yet to be included in a new release.
In the meantime, you can fix this by adding the following information to your requirements.txt file:
# fix for broken jinja
Running tests that include a graphical interface via Tox may cause issues with x11 permissions.
This can be resolved by installing this PyTest plugin: https://github.com/The-Compiler/pytest-xvfb
Documentation has not been updated to note this.
In Fall 2022, the Codio software stack was updated to Python 3.9. This requires several changes to be made to the projects, which are described below.
pip3 uninstall -y -r requirements.txt
On that page, select the latest version of the CC 410 Stack, and click Save.
The Codio box should update to the new stack.
Current versions are shown below:
tox.ini to use Python 3.9 instead of Python 3.6:
envlist = py39
Check the errata page to see if any requirements must be updated.
pip3 install -r requirements.txt
If there are any errors, contact the instructor.