Giter Club home page Giter Club logo

tdd-with-python's Introduction

#README.md

This is a summary document as I work through Test Driven Development with Python and hopefully learn Django in the process.

I'll include things like notes, sections, code snippets, and code I've worked through / modified in order to get things up and running.

Chaper 2

  • Use the unittest framework instead of simply writing functions

  • The def setUp and def tearDown are special functions inside of class uittest.TestCase to set up the function

Chapter 3

Difference Between Functional & Unit Tests

Functional Tests: test the application from the outside, from the point of view of the user.

Unit tests: test the application from the inside, from the point of view of the programmer.

NOTE: Functional tests should help you build an application with the right functionality, and guarantee you never accidentally break it. Unit tests should help you to write code that’s clean and bug free.

Creating a Django app (in this case lists)

It's incredibly easy to create a Django app (that lives inside of a project) using the $python manage.py startapp <app_name> syntax

Create an app within the superlists project called lists.

$python manage.py startapp lists

Now the doc-tree looks like:

├── db.sqlite3
├── functional_tests.py
├── lists
│   ├── admin.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── manage.py
└── superlists
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    ├── wsgi.py

Useful Functions from Chapter 3

Running the Django dev server

$python manage.py runserver

Running the functional tests

$python functional_tests.py

Running the unit tests

$python manage.py test

The unit-test/code cycle

  1. Run the unit tests in the terminal.
  2. Make a minimal code change in the editor.
  3. Repeat

tdd-with-python's People

Contributors

benjaminmgross avatar

Watchers

 avatar  avatar

Forkers

xg86

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.