makePythonTdd.shΒΆ

  • Here is the ./makePythonTdd.sh program from how to make a python test driven development environment

     1#!/bin/bash
     2PROJECT_NAME=$1
     3mkdir $PROJECT_NAME
     4cd $PROJECT_NAME
     5mkdir src
     6touch src/$PROJECT_NAME.py
     7mkdir tests
     8touch tests/__init__.py
     9
    10echo "import unittest
    11
    12
    13class Test$PROJECT_NAME(unittest.TestCase):
    14
    15    def test_failure(self):
    16        self.assertFalse(True)
    17
    18
    19# Exceptions Encountered
    20# AssertionError
    21" > tests/test_$PROJECT_NAME.py
    22
    23python3 -m venv .venv
    24source .venv/bin/activate
    25python3 -m pip install --upgrade pip
    26echo "pytest-watch" > requirements.txt
    27python3 -m pip install --requirement requirements.txt
    28pytest-watch
    
  • use chmod to make the program executable

    chmod +x makePythonTdd.sh
    
  • 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.sh is saved will make a Test Driven Development environment for a project called calculator

    ./makePythonTdd.sh calculator