From 2e68a063cce085e1b5467b82ba53d1da2779dcc2 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Thu, 22 Dec 2011 14:55:01 -0500 Subject: [PATCH 1/6] add placeholders for heroku, dotcloud, gondor --- docs/scenarios/web.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index e24af57..5367888 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -51,6 +51,14 @@ Nginx + gunicorn Hosting ::::::: +Heroku +------ + +DotCloud +-------- + +gondor.io +--------- ep.io ----- @@ -63,4 +71,4 @@ Twisted ::::::: -Node.js. \ No newline at end of file +Node.js. From 941e4c589f0eeac821e97dfb1c4e3427744ba800 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Thu, 22 Dec 2011 14:55:25 -0500 Subject: [PATCH 2/6] doc for Frameworks, WSGI, Django, Flask --- docs/scenarios/web.rst | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 5367888..0e33866 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -9,18 +9,67 @@ Context WSGI ---- +The Web Server Gateway Interface (or "WSGI" for short) is a standard +interface between web servers and Python web application frameworks. By +standardizing behavior and communication between web servers and Python web +frameworks, WSGI makes it possible to write portable Python web code that +can be deployed in any `WSGI-compliant web server <#servers>`_. WSGI is +documented in `PEP-3333 `_. + Frameworks :::::::::: +Broadly speaking, a web framework is a set of libraries upon which you can +build custom code to implement a web application (i.e. an interactive web +site). Most web frameworks include patterns and utilities to accomplish at +least the following: + +URL Routing + Matches an incoming HTTP request to a particular piece of Python code to + be invoked + +Request and Response Objects + Encapsulate the information received from or sent to a user's browser + +Template Engine + Allows for separating Python code implementing an application's logic from + the HTML (or other) output that it produces + +Development Web Server + Runs an HTTP server on development machines to enable rapid development; + often automatically reloads server-side code when files are updated + Django ------ +`Django `_ is a "batteries included" web +application framework. By providing many utilities and patterns out of the +box, Django aims to make it possible to build complex, database-backed web +applications quickly, while encouraging best practices in code written using +it. + +Django has a large and active community, and many pre-built `re-usable +modules `_ that can be incorporated into a new +project as-is, or customized to fit your needs. + +There are annual Django conferences `in the United States +`_ and `in Europe `_. + Flask ----- +`Flask `_ is a "microframework" for Python. Rather +than aiming to provide everything you could possibly need, Flask implements +the most commonly-used core components of a web application framework, like +URL routing, request and response objects, and templates. As a user of +Flask, it is therefore up to you to choose and integrate other components +you may need, such as database access or form generation and validation. For +many popular modules, `Extensions `_ may +already exist to suit your needs. + Pyramid ------- From 6a13fd5e594dc93815ba2be25b9300b1941f9239 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Thu, 22 Dec 2011 14:59:29 -0500 Subject: [PATCH 3/6] add some more hosts --- docs/scenarios/web.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 3fd4ae8..b1d2e83 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -62,6 +62,12 @@ Hosting ep.io ----- +Gondor +------ + +Heroku +------ + WebFaction ----------- From a91ca85a13db73f1ccfd394a1ff98869e8f1c41f Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Thu, 22 Dec 2011 15:03:20 -0500 Subject: [PATCH 4/6] adding Mongrel2 + Brubeck --- docs/scenarios/web.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 0e33866..b389273 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -96,6 +96,9 @@ Apache + mod_python Nginx + gunicorn ---------------- +Mongrel2 + Brubeck +------------------ + Hosting ::::::: From 9e0eb0b79f660757a709cc208cebbf7a24c71cf4 Mon Sep 17 00:00:00 2001 From: Kamil Kisiel Date: Thu, 22 Dec 2011 14:58:48 -0800 Subject: [PATCH 5/6] Fleshed out the tests documentation The doctest bit still needs some work, I've never really used it myself so not sure what the benefits are :) --- docs/writing/tests.rst | 131 +++++++++++++++++++++++++++++++++++------ 1 file changed, 112 insertions(+), 19 deletions(-) diff --git a/docs/writing/tests.rst b/docs/writing/tests.rst index fa0ef17..90a63df 100644 --- a/docs/writing/tests.rst +++ b/docs/writing/tests.rst @@ -11,55 +11,148 @@ The Basics Unittest -------- +Unittest is the batteries-included test module in the Python standard library. +Its API will be familiar to anyone who has used any of the JUnit/nUnit/CppUnit +series of tools. + +Creating testcases is accomplished by subclassing a TestCase base class + +:: + + import unittest + + def fun(x): + return x + 1 + + class MyTest(unittest.TestCase): + def test(self): + self.assertEqual(fun(3), 4) + +As of Python 2.7 unittest also includes its own test discovery mechanisms. + + `unittest in the standard library documentation `_ -Doc Strings ------------ - +Doctest +------- +The doctest module searches for pieces of text that look like interactive Python +sessions, and then executes those sessions to verify that they work exactly as +shown. Tools ::::: -Doctest -------- - - py.test ------- +py.test is a no-boilerplate alternative to Python's standard unittest module. + :: $ pip install pytest +Despite being a fully-featured and extensible test tool it boasts a simple +syntax. Creating a test suite is as easy as writing a module with a couple of +functions + +:: + + # content of test_sample.py + def func(x): + return x + 1 + + def test_answer(): + assert func(3) == 5 + +and then running the `py.test` command + +:: + + $ py.test + =========================== test session starts ============================ + platform darwin -- Python 2.7.1 -- pytest-2.2.1 + collecting ... collected 1 items + + test_sample.py F + + ================================= FAILURES ================================= + _______________________________ test_answer ________________________________ + + def test_answer(): + > assert func(3) == 5 + E assert 4 == 5 + E + where 4 = func(3) + + test_sample.py:5: AssertionError + ========================= 1 failed in 0.02 seconds ========================= + +far less work than would be required for the equivalent functionality with the +unittest module! + + `py.test `_ + Nose ---- - -:: - - $ pip install tox - - - -Unittest2 ---------- - -A backport of Python 2.7's +nose extends unittest to make testing easier. :: - $ pip install tox + $ pip install nose + +nose provides automatic test discovery to save you the hassle of manually +creating test suites. It also provides numerous plugins for features such as +xUnit-compatible test output, coverage reporting, and test selection. + + `nose `_ tox --- +tox is a tool for automating test environment management and testing against multiple +interpreter configurations :: $ pip install tox + +tox allows you to configure complicatated multi-parameter test matrices via a +simple ini-style configuration file. + + `tox `_ + +Unittest2 +--------- + +unittest2 is a a backport of Python 2.7's unittest module which has an improved +API and better assertions over the one available in previous versions of Python. + +If you're using Python 2.6 or below, you can install it with pip + +:: + + $ pip install unittest2 + +You may want to import the module under the name unittest to make porting code +to newer versions of the module easier in the future + +:: + + import unittest2 as unittest + + class MyTest(unittest.TestCase): + ... + +This way if you ever switch to a newer python version and no longer need the +unittest2 module, you can simply change the import in your test module without +the need to change any other code. + + `unittest2 `_ + + From a24c606070baf89050a871d60e83e0bdf34eb48b Mon Sep 17 00:00:00 2001 From: Kamil Kisiel Date: Thu, 22 Dec 2011 15:02:44 -0800 Subject: [PATCH 6/6] Added myself to AUTHORS --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 002f068..a2dae26 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,2 +1,3 @@ Kenneth Reitz -Johannes Seitz \ No newline at end of file +Johannes Seitz +Kamil Kisiel