makePythonTdd.ps1
makePythonTdd.sh program
Here is the
makePythonTdd.ps1program from how to make a python test driven development environment on Windows without Windows Subsystem for Linux1$PROJECT_NAME=$args[0] 2mkdir $PROJECT_NAME 3cd $PROJECT_NAME 4mkdir src 5New-Item "src/$PROJECT_NAME.py" 6mkdir tests 7New-Item tests/__init__.py 8 9"import unittest 10 11 12class Test$($PROJECT_NAME)(unittest.TestCase): 13 14 def test_failure(self): 15 self.assertFalse(True) 16 17 18# Exceptions seen 19# AssertionError 20" | Out-File "tests/test_$PROJECT_NAME.py" -Encoding UTF8 21 22python -m venv .venv 23.venv/scripts/activate.ps1 24python -m pip install --upgrade pip 25"pytest-watcher" | Out-File requirements.txt -Encoding UTF8 26python -m pip install --requirement requirements.txt 27pytest-watchergive 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 wheremakePythonTdd.ps1is saved makes a Test Driven Development environment for a project with the name person./makePythonTdd.ps1 person
BONUS: makePythonTdd.ps1 Pro
Since you are the adventurous type and made it in here, I have added 2 lines for you that automate opening the test file and source file for the projects
1$PROJECT_NAME=$args[0]
2mkdir $PROJECT_NAME
3cd $PROJECT_NAME
4mkdir src
5New-Item "src/$PROJECT_NAME.py"
6mkdir tests
7New-Item tests/__init__.py
8
9"import unittest
10
11
12class Test$($PROJECT_NAME)(unittest.TestCase):
13
14 def test_failure(self):
15 self.assertFalse(True)
16
17
18# Exceptions seen
19# AssertionError
20" | Out-File "tests/test_$PROJECT_NAME.py" -Encoding UTF8
21
22code src/$PROJECT_NAME.py
23code tests/test_$PROJECT_NAME.py
24
25python -m venv .venv
26.venv/scripts/activate.ps1
27python -m pip install --upgrade pip
28"pytest-watcher" | Out-File requirements.txt -Encoding UTF8
29python -m pip install --requirement requirements.txt
30pytest-watcher
this works with Visual Studio Code you can change it to use the command for any Integrated Development Environment (IDE) you like