Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.13
27 changes: 20 additions & 7 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@

Skeleton project for Python.

## Usage (on MacOS / Linux)
- `./script/setup` to install dependencies (uses [homebrew](https://brew.sh/))
- `./script/test` to run the tests
## Prerequisites

The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions):

```
python 3.13
```

Install those however you prefer, as long as they end up on your `PATH`. The quickest route is
[mise](https://mise.jdx.dev/), which reads the file for you:

## Usage (on Windows)
- Install Python 3. You can either download from https://www.python.org/downloads/ or run `python` in a terminal to open Windows store Python download.
- Run `./script/test.bat` in terminal to run tests
```sh
mise install
```

## Usage
- `./script/setup` to create the virtual environment
- `./script/test` to run the tests
- `./script/start` to run the exercise

## Structure
- Code located in [`pairing_exercise.py`](./pairing_exercise.py)
- Tests located in [`test_pairing_exercise.py`](./test_pairing_exercise.py)

However, you're free to organise your code as you like.
However, you're free to organise your code as you like.

15 changes: 6 additions & 9 deletions python/script/setup
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/env bash

set -e
set -euo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd "$DIR"
cd "$(dirname "${BASH_SOURCE[0]}")/.."

brew install python3
python3 -m venv venv

pip3 install virtualenv

virtualenv ../venv

popd
if [[ -f requirements.txt ]]; then
venv/bin/pip install -r requirements.txt
fi
7 changes: 7 additions & 0 deletions python/script/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

venv/bin/python pairing_exercise.py
6 changes: 3 additions & 3 deletions python/script/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

set -e
set -euo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$(dirname "${BASH_SOURCE[0]}")/.."

"$DIR"/../venv/bin/python -m unittest discover
venv/bin/python -m unittest discover
9 changes: 0 additions & 9 deletions python/script/test.bat

This file was deleted.

Loading