Skip to content

thompson318/sunflower-tests

Repository files navigation

Sunflower Tests - A Small Repository for Exploring Test Methods

Installation

You can use the qr tag to link to this page.

A QR tag linking to this repository.

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 ... An image of a sunflower

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

Consider how we can test this code.

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.

Setup.

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 1. Build an end to end test.

Excercise 2. Create a test for the fibonacci function.

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?

Further Reading and tests in other languages.

Further Reading

Acknowledgements

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages