makePythonTdd
makePythonTdd with no variables
Here is the program_ from how to make a Python Test Driven Development environment automatically
1#!/bin/bash 2uv init more_magic 3cd more_magic 4mkdir src 5mv main.py src/more_magic.py 6mkdir tests 7touch tests/__init__.py 8 9echo "import unittest 10 11 12class TestMoreMagic(unittest.TestCase): 13 14 def test_failure(self): 15 self.assertFalse(True) 16 17 18# Exceptions seen 19# AssertionError 20" > tests/test_more_magic.py 21 22echo "pytest" > requirements.txt 23echo "pytest-watcher" >> requirements.txt 24uv add --requirement requirements.txt 25uv run pytest-watcher . --now1uv init more_magic 2cd more_magic 3mkdir src 4Move-Item "main.py" "src/more_magic.py" 5mkdir tests 6New-Item tests/__init__.py 7 8"import unittest 9 10 11class TestMoreMagic(unittest.TestCase): 12 13 def test_failure(self): 14 self.assertFalse(True) 15 16 17# Exceptions seen 18# AssertionError 19" | Out-File "tests/test_more_magic.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 . --nowchange
more_magicto the name of your Project and when the program_ is called to make a `Test Driven Development`_ any time you wanttype this in the terminal_ to run the program_
./makePythonTdd.sh.\makePythonTdd.ps1
makePythonTdd with variables
Here is the program_ from how to make a Python Test Driven Development environment 3
use
chmodto make the program_ executablechmod +x makePythonTdd.sh
give a name for the
PROJECT_NAMEvariable when the program_ is called to make a `Test Driven Development`_ any time you want. For example typing this command in the terminal_ in the folder_ where the program_ is saved makes a Test Driven Development environment for a project with the name person./makePythonTdd.sh person.\makePythonTdd.ps1 person
BONUS: makePythonTdd.sh Pro
Since you are the adventurous type and made it this deep in the book, I have added extra lines that
make the project with
PROJECT_NAMEas the name if you do not give a namemake the class name in CapWords format
open the test file_ and source file_ in your editor
code src/$PROJECT_NAME.py and code tests/test_$PROJECT_NAME.py work with `Visual Studio Code`_ you can change code to use the command for any `Integrated Development Environment (IDE)`_ you like