Parking Garage: tests and solutions


makePythonTdd ParkingGarage

the code in makePythonTdd.sh from ParkingGarage

 1#!/bin/bash
 2uv init atm
 3cd atm
 4mkdir src
 5mv main.py src/atm.py
 6mkdir tests
 7touch tests/__init__.py
 8
 9echo "import unittest
10
11
12class TestATM(unittest.TestCase):
13
14    def test_failure(self):
15        self.assertFalse(True)
16
17
18# Exceptions seen
19# AssertionError
20" > tests/test_atm.py
21
22echo "pytest" > requirements.txt
23echo "pytest-watcher" >> requirements.txt
24uv add --requirement requirements.txt
25uv run pytest-watcher . --now

the code in makePythonTdd.ps1 from ParkingGarage

 1uv init atm
 2cd atm
 3mkdir src
 4Move-Item "main.py" "src/atm.py"
 5mkdir tests
 6New-Item tests/__init__.py
 7
 8"import unittest
 9
10
11class TestATM(unittest.TestCase):
12
13    def test_failure(self):
14        self.assertFalse(True)
15
16
17# Exceptions seen
18# AssertionError
19" | Out-File "tests/test_atm.py" -Encoding UTF8
20
21"pytest" | Out-File requirements.txt -Encoding UTF8
22"pytest-watcher" >> requirements.txt
23uv add --requirement requirements.txt
24uv run pytest-watcher . --now

Parking Garage: tests

the code in parking_garage/tests/test_parking_garage.py from ParkingGarage

1

Parking Garage: solution

the code in parking_garage/src/parking_garage.py from ParkingGarage

1