These are my notes from the book Test-Driven Development with Python.
I've used the book as a guide, and deviated occasionally.
- The book uses Python 3.6 and Django 1.11.
- I'm using Python 3.7, Django 1.11, macOS 10.15, and Homebrew 2.2.
- "venv" is the general convention used globally.
First, install dependencies and create the environment.
# Install Homebrew.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install the project dependencies.
brew install python3
brew install geckodriver
brew cask install firefox
# Create a Git repository.
git init ~/src/myproject
cd ~/src/myproject
# Create a virtual environment, in the directory "venv".
python3 -m venv virtualenv venv
# Create a .gitignore file.
echo '*.log' >> .gitignore
echo '*.pyc' >> .gitignore
echo '__pycache__' >> .gitignore
echo 'db.sqlite3' >> .gitignore
echo 'venv' >> .gitignore
git add .gitignore
# Commit the .gitignore file.
git commit -m "Add a .gitignore file."
For development and testing, activate virtualenv with this command:
source venv/bin/activate
Once you've activated the virtualenv, install Django & Selenium:
pip install "django<1.12" "selenium<4"
When you're done with development and testing, deactivate virtualenv:
deactivate
Create a new Django project:
django-admin startproject myproject .
Start a web server:
python manage.py runserver
Run my functional tests.
python functional_tests.py
Released as open source software under the terms of the ISC License.