You can use the qr tag to link to this page.
We recomend using uv to install and run this software. If you haven't already done so please follow these instructions to install uv.
git clone https://github.com/thompson318/sunflower-tests.git # clone the repository
cd sunflower-tests # enter the directory
uv venv # create a virtual environment
source .venv/bin/activate # and activate it
uv pip install -r requirements.txt # use uv to install necessary libraries
python sunflower_maker.py # run the code.
Running the program should have created the file sunflower.svg. You should be able to view it with it with a image viewer or webrowser.
It should look like this ...
You should be able to change the size of the image by passing an extra command line parameter (an integer from 0 to 5)
python sunflower_maker.py 4
The repository is set up to allow you to use pytest to test your code locally ...
pytest
And a github actions workflow to enable running tests using GitHubs CI test machines.
For the remainder of the session we will create new tests and use test driven development to add new features using those tests.
Start by creating your own fork of the repository using GitHub's web interface. Clone the fork to your machine, and start coding with your editor / IDE of choice. You can create tests and code, test locally, then push to Github, where the tests should run using GitHub's CI machines. When ready you can create a pull request back to this repository for review and discussion.
Excercise 3. Extend the test to higher (arbitrary) values of rank and use the test as you reimplement the fibonacci function to work on any rank value.
Extensions. Think about other things that may go wrong. What do we expect the function to do if we pass a non integer or negative value. How do we test to make sure that happens?
Image attribution: By Fir0002 - Own work, GFDL 1.2, https://commons.wikimedia.org/w/index.php?curid=7613324
Emoji One, CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0, via Wikimedia Commons
