makePythonTdd.ps1ΒΆ

  • Here is the ./makePythonTdd.ps1 program from how to make a python test driven development environment on Windows without Windows Subsystem Linux

     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 Encountered
    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-watch" | Out-File requirements.txt -Encoding UTF8
    26python -m pip install --requirement requirements.txt
    27pytest-watch
    
  • give a name for the $PROJECT_NAME variable 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 makePythonTdd.ps1 is saved will make a Test Driven Development environment for a project called calculator

    ./makePythonTdd.ps1 calculator