[Python-modules-commits] [pytest-localserver] 02/14: Import pytest-localserver_0.3.5.orig.tar.xz
Daniel Stender
danstender-guest at moszumanska.debian.org
Fri Mar 18 17:45:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
danstender-guest pushed a commit to branch master
in repository pytest-localserver.
commit c915ba72bf1441d3b81f52883abd5dc5c291d14a
Author: Daniel Stender <stender at debian.org>
Date: Fri Mar 18 13:13:17 2016 +0100
Import pytest-localserver_0.3.5.orig.tar.xz
---
PKG-INFO | 446 ++++++++++++++++---------------
pytest_localserver.egg-info/PKG-INFO | 446 ++++++++++++++++---------------
pytest_localserver.egg-info/SOURCES.txt | 2 +
pytest_localserver.egg-info/requires.txt | 2 +-
pytest_localserver/__init__.py | 2 +-
pytest_localserver/server.csr | 28 ++
pytest_localserver/server.pem.orig | 81 ++++++
pytest_localserver/smtp.py | 2 +-
setup.cfg | 10 +-
setup.py | 4 +-
tests/test_smtp.py | 2 +-
tox.ini | 2 +-
12 files changed, 572 insertions(+), 455 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index b87625a..6de3063 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,222 +1,224 @@
-Metadata-Version: 1.1
-Name: pytest-localserver
-Version: 0.3.4
-Summary: py.test plugin to test server connections locally.
-Home-page: http://bitbucket.org/basti/pytest-localserver/
-Author: Sebastian Rahlf
-Author-email: basti AT redtoad DOT de
-License: MIT License
-Download-URL: http://bitbucket.org/basti/pytest-localserver/downloads/
-Description: ==================
- pytest-localserver
- ==================
-
- pytest-localserver is a plugin for the `pytest`_ testing framework which enables
- you to test server connections locally.
-
- Sometimes `monkeypatching`_ ``urllib2.urlopen()`` just does not cut it, for
- instance if you work with ``urllib2.Request``, define your own openers/handlers
- or work with ``httplib``. In these cases it may come in handy to have an HTTP
- server running locally which behaves just like the real thing [1]_. Well, look
- no further!
-
- Quickstart
- ==========
-
- Let's say you have a function to scrape HTML which only required to be pointed
- at a URL ::
-
- import requests
- def scrape(url):
- html = requests.get(url).text
- # some parsing happens here
- # ...
- return result
-
- You want to test this function in its entirety without having to rely on a
- remote server whose content you cannot control, neither do you want to waste
- time setting up a complex mechanism to mock or patch the underlying Python
- modules dealing with the actual HTTP request (of which there are more than one
- BTW). So what do you do?
-
- You simply use pytest's `funcargs feature`_ and simulate an entire server
- locally! ::
-
- def test_retrieve_some_content(httpserver):
- httpserver.serve_content(open('cached-content.html').read())
- assert scrape(httpserver.url) == 'Found it!'
-
- What happened here is that for the duration of your tests an HTTP server is
- started on a random port on localhost which will serve the content you tell it
- to and behaves just like the real thing.
-
- The added bonus is that you can test whether your code behaves gracefully if
- there is a network problem::
-
- def test_content_retrieval_fails_graciously(httpserver):
- httpserver.serve_content('File not found!', 404)
- pytest.raises(ContentNotFoundException, scrape, httpserver.url)
-
- The same thing works for SMTP servers, too::
-
- def test_sending_some_message(smtpserver):
- mailer = MyMailer(host=smtpserver.addr[0], port=smtpserver.addr[1])
- mailer.send(to='bob at example.com', from_='alice at example.com',
- subject='MyMailer v1.0', body='Check out my mailer!')
- assert len(smtpserver.outbox)==1
-
- Here an SMTP server is started which accepts e-mails being sent to it. The
- nice feature here is that you can actually check if the message was received
- and what was sent by looking into the smtpserver's ``outbox``.
-
- It is really that easy!
-
- Available funcargs
- ==================
-
- Here is a short overview of the available funcargs. For more details I suggest
- poking around in the code itself.
-
- ``httpserver``
- provides a threaded HTTP server instance running on localhost. It has the
- following attributes:
-
- * ``code`` - HTTP response code (int)
- * ``content`` - content of next response (str)
- * ``headers`` - response headers (dict)
-
- Once these attribute are set, all subsequent requests will be answered with
- these values until they are changed or the server is stopped. A more
- convenient way to change these is ::
-
- httpserver.serve_content(content=None, code=200, headers=None)
-
- The server address can be found in property
-
- * ``url``
-
- which is the string representation of tuple ``server_address`` (host as str,
- port as int).
-
- If you want to check which form fields have been POSTed, Try ::
-
- httpserver.serve_content(..., show_post_vars=True)
-
- which will display them as parsable text.
-
- ``httpsserver``
- is the same as ``httpserver`` only with SSL encryption.
-
- ``smtpserver``
- provides a threaded instance of ``smtpd.SMTPServer`` runnning on localhost.
- It has the following attributes:
-
- * ``addr`` - server address as tuple (host as str, port as int)
- * ``outbox`` - list of ``email.message.Message`` instances received.
-
- Using your a WSGI application as test server
- ============================================
-
- As of version 0.3 you can now use a `WSGI application`_ to run on the test
- server ::
-
- from pytest_localserver.http import WSGIServer
-
- def simple_app(environ, start_response):
- """Simplest possible WSGI application"""
- status = '200 OK'
- response_headers = [('Content-type', 'text/plain')]
- start_response(status, response_headers)
- return ['Hello world!\n']
-
- def pytest_funcarg__testserver(request):
- """Defines the testserver funcarg"""
- server = WSGIServer(application=simple_app)
- server.start()
- request.addfinalizer(server.stop)
- return server
-
- def test_retrieve_some_content(testserver):
- assert scrape(testserver.url) == 'Hello world!\n'
-
- Have a look at the following page for more information on WSGI:
- http://wsgi.readthedocs.org/en/latest/learn.html
-
- Download and Installation
- =========================
-
- You can install the plugin by running ::
-
- pip install pytest-localserver
-
- Alternatively, get the latest stable version from `PyPI`_ or the latest
- `bleeding-edge archive`_ from bitbucket.org.
-
- License and Credits
- ===================
-
- This plugin is released under the MIT license. You can find the full text of
- the license in the LICENSE file.
-
- Copyright (C) 2010-2013 Sebastian Rahlf and others (see AUTHORS).
-
- Some parts of this package is based on ideas or code from other people:
-
- - I borrowed some implementation ideas for the httpserver from `linkchecker`_.
- - The implementation for the SMTP server is based on the `Mailsink recipe`_ by
- Adam Feuer, Matt Branthwaite and Troy Frever.
- - The HTTPS implementation is based on work by `Sebastien Martini`_.
-
- Thanks guys!
-
- Development and future plans
- ============================
-
- Feel free to clone the repository and add your own changes. Pull requests are
- always welcome!::
-
- hg clone https://bitbucket.org/basti/pytest-localserver
-
- If you find any bugs, please file a `report`_.
-
- Test can be run with tox. Note that you need virtualenv<1.8 to run tests for
- Python 2.4.
-
- I already have a couple of ideas for future versions:
-
- * support for FTP, SSH (maybe base all on twisted?)
- * making the SMTP outbox as convenient to use as ``django.core.mail.outbox``
- * add your own here!
-
- ----
-
- .. [1] The idea for this project was born when I needed to check that `a piece
- of software`_ behaved itself when receiving HTTP error codes 404 and 500.
- Having unsuccessfully tried to mock a server, I stumbled across
- `linkchecker`_ which uses a the same idea to test its internals.
-
- .. _monkeypatching: http://pytest.org/latest/monkeypatch.html
- .. _pytest: http://pytest.org/
- .. _funcargs feature: http://pytest.org/latest/funcargs.html
- .. _linkchecker: http://linkchecker.sourceforge.net/
- .. _WSGI application: http://www.python.org/dev/peps/pep-0333/
- .. _PyPI: http://pypi.python.org/pypi/pytest-localserver/
- .. _bleeding-edge archive: https://bitbucket.org/basti/pytest-localserver/get/tip.tar.gz
- .. _report: https://bitbucket.org/basti/pytest-localserver/issues/
- .. _tox: http://testrun.org/tox/
- .. _a piece of software: http://pypi.python.org/pypi/python-amazon-product-api/
- .. _Mailsink recipe: http://code.activestate.com/recipes/440690/
- .. _Sebastien Martini: http://code.activestate.com/recipes/442473/
-
-Keywords: py.test pytest server localhost http smtp
-Platform: UNKNOWN
-Classifier: Operating System :: OS Independent
-Classifier: Development Status :: 4 - Beta
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Topic :: Software Development :: Testing
+Metadata-Version: 1.1
+Name: pytest-localserver
+Version: 0.3.5
+Summary: py.test plugin to test server connections locally.
+Home-page: http://bitbucket.org/basti/pytest-localserver/
+Author: Sebastian Rahlf
+Author-email: basti AT redtoad DOT de
+License: MIT License
+Download-URL: http://bitbucket.org/basti/pytest-localserver/downloads/
+Description: ==================
+ pytest-localserver
+ ==================
+
+ pytest-localserver is a plugin for the `pytest`_ testing framework which enables
+ you to test server connections locally.
+
+ Sometimes `monkeypatching`_ ``urllib2.urlopen()`` just does not cut it, for
+ instance if you work with ``urllib2.Request``, define your own openers/handlers
+ or work with ``httplib``. In these cases it may come in handy to have an HTTP
+ server running locally which behaves just like the real thing [1]_. Well, look
+ no further!
+
+ Quickstart
+ ==========
+
+ Let's say you have a function to scrape HTML which only required to be pointed
+ at a URL ::
+
+ import requests
+ def scrape(url):
+ html = requests.get(url).text
+ # some parsing happens here
+ # ...
+ return result
+
+ You want to test this function in its entirety without having to rely on a
+ remote server whose content you cannot control, neither do you want to waste
+ time setting up a complex mechanism to mock or patch the underlying Python
+ modules dealing with the actual HTTP request (of which there are more than one
+ BTW). So what do you do?
+
+ You simply use pytest's `funcargs feature`_ and simulate an entire server
+ locally! ::
+
+ def test_retrieve_some_content(httpserver):
+ httpserver.serve_content(open('cached-content.html').read())
+ assert scrape(httpserver.url) == 'Found it!'
+
+ What happened here is that for the duration of your tests an HTTP server is
+ started on a random port on localhost which will serve the content you tell it
+ to and behaves just like the real thing.
+
+ The added bonus is that you can test whether your code behaves gracefully if
+ there is a network problem::
+
+ def test_content_retrieval_fails_graciously(httpserver):
+ httpserver.serve_content('File not found!', 404)
+ pytest.raises(ContentNotFoundException, scrape, httpserver.url)
+
+ The same thing works for SMTP servers, too::
+
+ def test_sending_some_message(smtpserver):
+ mailer = MyMailer(host=smtpserver.addr[0], port=smtpserver.addr[1])
+ mailer.send(to='bob at example.com', from_='alice at example.com',
+ subject='MyMailer v1.0', body='Check out my mailer!')
+ assert len(smtpserver.outbox)==1
+
+ Here an SMTP server is started which accepts e-mails being sent to it. The
+ nice feature here is that you can actually check if the message was received
+ and what was sent by looking into the smtpserver's ``outbox``.
+
+ It is really that easy!
+
+ Available funcargs
+ ==================
+
+ Here is a short overview of the available funcargs. For more details I suggest
+ poking around in the code itself.
+
+ ``httpserver``
+ provides a threaded HTTP server instance running on localhost. It has the
+ following attributes:
+
+ * ``code`` - HTTP response code (int)
+ * ``content`` - content of next response (str)
+ * ``headers`` - response headers (dict)
+
+ Once these attribute are set, all subsequent requests will be answered with
+ these values until they are changed or the server is stopped. A more
+ convenient way to change these is ::
+
+ httpserver.serve_content(content=None, code=200, headers=None)
+
+ The server address can be found in property
+
+ * ``url``
+
+ which is the string representation of tuple ``server_address`` (host as str,
+ port as int).
+
+ If you want to check which form fields have been POSTed, Try ::
+
+ httpserver.serve_content(..., show_post_vars=True)
+
+ which will display them as parsable text.
+
+ ``httpsserver``
+ is the same as ``httpserver`` only with SSL encryption.
+
+ ``smtpserver``
+ provides a threaded instance of ``smtpd.SMTPServer`` runnning on localhost.
+ It has the following attributes:
+
+ * ``addr`` - server address as tuple (host as str, port as int)
+ * ``outbox`` - list of ``email.message.Message`` instances received.
+
+ Using your a WSGI application as test server
+ ============================================
+
+ As of version 0.3 you can now use a `WSGI application`_ to run on the test
+ server ::
+
+ from pytest_localserver.http import WSGIServer
+
+ def simple_app(environ, start_response):
+ """Simplest possible WSGI application"""
+ status = '200 OK'
+ response_headers = [('Content-type', 'text/plain')]
+ start_response(status, response_headers)
+ return ['Hello world!\n']
+
+ def pytest_funcarg__testserver(request):
+ """Defines the testserver funcarg"""
+ server = WSGIServer(application=simple_app)
+ server.start()
+ request.addfinalizer(server.stop)
+ return server
+
+ def test_retrieve_some_content(testserver):
+ assert scrape(testserver.url) == 'Hello world!\n'
+
+ Have a look at the following page for more information on WSGI:
+ http://wsgi.readthedocs.org/en/latest/learn.html
+
+ Download and Installation
+ =========================
+
+ You can install the plugin by running ::
+
+ pip install pytest-localserver
+
+ Alternatively, get the latest stable version from `PyPI`_ or the latest
+ `bleeding-edge archive`_ from bitbucket.org.
+
+ License and Credits
+ ===================
+
+ This plugin is released under the MIT license. You can find the full text of
+ the license in the LICENSE file.
+
+ Copyright (C) 2010-2013 Sebastian Rahlf and others (see AUTHORS).
+
+ Some parts of this package is based on ideas or code from other people:
+
+ - I borrowed some implementation ideas for the httpserver from `linkchecker`_.
+ - The implementation for the SMTP server is based on the `Mailsink recipe`_ by
+ Adam Feuer, Matt Branthwaite and Troy Frever.
+ - The HTTPS implementation is based on work by `Sebastien Martini`_.
+
+ Thanks guys!
+
+ Development and future plans
+ ============================
+
+ Feel free to clone the repository and add your own changes. Pull requests are
+ always welcome!::
+
+ hg clone https://bitbucket.org/basti/pytest-localserver
+
+ If you find any bugs, please file a `report`_.
+
+ Test can be run with tox. Note that you need virtualenv<1.8 to run tests for
+ Python 2.4.
+
+ I already have a couple of ideas for future versions:
+
+ * support for FTP, SSH (maybe base all on twisted?)
+ * making the SMTP outbox as convenient to use as ``django.core.mail.outbox``
+ * add your own here!
+
+ ----
+
+ .. [1] The idea for this project was born when I needed to check that `a piece
+ of software`_ behaved itself when receiving HTTP error codes 404 and 500.
+ Having unsuccessfully tried to mock a server, I stumbled across
+ `linkchecker`_ which uses a the same idea to test its internals.
+
+ .. _monkeypatching: http://pytest.org/latest/monkeypatch.html
+ .. _pytest: http://pytest.org/
+ .. _funcargs feature: http://pytest.org/latest/funcargs.html
+ .. _linkchecker: http://linkchecker.sourceforge.net/
+ .. _WSGI application: http://www.python.org/dev/peps/pep-0333/
+ .. _PyPI: http://pypi.python.org/pypi/pytest-localserver/
+ .. _bleeding-edge archive: https://bitbucket.org/basti/pytest-localserver/get/tip.tar.gz
+ .. _report: https://bitbucket.org/basti/pytest-localserver/issues/
+ .. _tox: http://testrun.org/tox/
+ .. _a piece of software: http://pypi.python.org/pypi/python-amazon-product-api/
+ .. _Mailsink recipe: http://code.activestate.com/recipes/440690/
+ .. _Sebastien Martini: http://code.activestate.com/recipes/442473/
+
+Keywords: py.test pytest server localhost http smtp
+Platform: UNKNOWN
+Classifier: Operating System :: OS Independent
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Software Development :: Testing
diff --git a/pytest_localserver.egg-info/PKG-INFO b/pytest_localserver.egg-info/PKG-INFO
index b87625a..6de3063 100644
--- a/pytest_localserver.egg-info/PKG-INFO
+++ b/pytest_localserver.egg-info/PKG-INFO
@@ -1,222 +1,224 @@
-Metadata-Version: 1.1
-Name: pytest-localserver
-Version: 0.3.4
-Summary: py.test plugin to test server connections locally.
-Home-page: http://bitbucket.org/basti/pytest-localserver/
-Author: Sebastian Rahlf
-Author-email: basti AT redtoad DOT de
-License: MIT License
-Download-URL: http://bitbucket.org/basti/pytest-localserver/downloads/
-Description: ==================
- pytest-localserver
- ==================
-
- pytest-localserver is a plugin for the `pytest`_ testing framework which enables
- you to test server connections locally.
-
- Sometimes `monkeypatching`_ ``urllib2.urlopen()`` just does not cut it, for
- instance if you work with ``urllib2.Request``, define your own openers/handlers
- or work with ``httplib``. In these cases it may come in handy to have an HTTP
- server running locally which behaves just like the real thing [1]_. Well, look
- no further!
-
- Quickstart
- ==========
-
- Let's say you have a function to scrape HTML which only required to be pointed
- at a URL ::
-
- import requests
- def scrape(url):
- html = requests.get(url).text
- # some parsing happens here
- # ...
- return result
-
- You want to test this function in its entirety without having to rely on a
- remote server whose content you cannot control, neither do you want to waste
- time setting up a complex mechanism to mock or patch the underlying Python
- modules dealing with the actual HTTP request (of which there are more than one
- BTW). So what do you do?
-
- You simply use pytest's `funcargs feature`_ and simulate an entire server
- locally! ::
-
- def test_retrieve_some_content(httpserver):
- httpserver.serve_content(open('cached-content.html').read())
- assert scrape(httpserver.url) == 'Found it!'
-
- What happened here is that for the duration of your tests an HTTP server is
- started on a random port on localhost which will serve the content you tell it
- to and behaves just like the real thing.
-
- The added bonus is that you can test whether your code behaves gracefully if
- there is a network problem::
-
- def test_content_retrieval_fails_graciously(httpserver):
- httpserver.serve_content('File not found!', 404)
- pytest.raises(ContentNotFoundException, scrape, httpserver.url)
-
- The same thing works for SMTP servers, too::
-
- def test_sending_some_message(smtpserver):
- mailer = MyMailer(host=smtpserver.addr[0], port=smtpserver.addr[1])
- mailer.send(to='bob at example.com', from_='alice at example.com',
- subject='MyMailer v1.0', body='Check out my mailer!')
- assert len(smtpserver.outbox)==1
-
- Here an SMTP server is started which accepts e-mails being sent to it. The
- nice feature here is that you can actually check if the message was received
- and what was sent by looking into the smtpserver's ``outbox``.
-
- It is really that easy!
-
- Available funcargs
- ==================
-
- Here is a short overview of the available funcargs. For more details I suggest
- poking around in the code itself.
-
- ``httpserver``
- provides a threaded HTTP server instance running on localhost. It has the
- following attributes:
-
- * ``code`` - HTTP response code (int)
- * ``content`` - content of next response (str)
- * ``headers`` - response headers (dict)
-
- Once these attribute are set, all subsequent requests will be answered with
- these values until they are changed or the server is stopped. A more
- convenient way to change these is ::
-
- httpserver.serve_content(content=None, code=200, headers=None)
-
- The server address can be found in property
-
- * ``url``
-
- which is the string representation of tuple ``server_address`` (host as str,
- port as int).
-
- If you want to check which form fields have been POSTed, Try ::
-
- httpserver.serve_content(..., show_post_vars=True)
-
- which will display them as parsable text.
-
- ``httpsserver``
- is the same as ``httpserver`` only with SSL encryption.
-
- ``smtpserver``
- provides a threaded instance of ``smtpd.SMTPServer`` runnning on localhost.
- It has the following attributes:
-
- * ``addr`` - server address as tuple (host as str, port as int)
- * ``outbox`` - list of ``email.message.Message`` instances received.
-
- Using your a WSGI application as test server
- ============================================
-
- As of version 0.3 you can now use a `WSGI application`_ to run on the test
- server ::
-
- from pytest_localserver.http import WSGIServer
-
- def simple_app(environ, start_response):
- """Simplest possible WSGI application"""
- status = '200 OK'
- response_headers = [('Content-type', 'text/plain')]
- start_response(status, response_headers)
- return ['Hello world!\n']
-
- def pytest_funcarg__testserver(request):
- """Defines the testserver funcarg"""
- server = WSGIServer(application=simple_app)
- server.start()
- request.addfinalizer(server.stop)
- return server
-
- def test_retrieve_some_content(testserver):
- assert scrape(testserver.url) == 'Hello world!\n'
-
- Have a look at the following page for more information on WSGI:
- http://wsgi.readthedocs.org/en/latest/learn.html
-
- Download and Installation
- =========================
-
- You can install the plugin by running ::
-
- pip install pytest-localserver
-
- Alternatively, get the latest stable version from `PyPI`_ or the latest
- `bleeding-edge archive`_ from bitbucket.org.
-
- License and Credits
- ===================
-
- This plugin is released under the MIT license. You can find the full text of
- the license in the LICENSE file.
-
- Copyright (C) 2010-2013 Sebastian Rahlf and others (see AUTHORS).
-
- Some parts of this package is based on ideas or code from other people:
-
- - I borrowed some implementation ideas for the httpserver from `linkchecker`_.
- - The implementation for the SMTP server is based on the `Mailsink recipe`_ by
- Adam Feuer, Matt Branthwaite and Troy Frever.
- - The HTTPS implementation is based on work by `Sebastien Martini`_.
-
- Thanks guys!
-
- Development and future plans
- ============================
-
- Feel free to clone the repository and add your own changes. Pull requests are
- always welcome!::
-
- hg clone https://bitbucket.org/basti/pytest-localserver
-
- If you find any bugs, please file a `report`_.
-
- Test can be run with tox. Note that you need virtualenv<1.8 to run tests for
- Python 2.4.
-
- I already have a couple of ideas for future versions:
-
- * support for FTP, SSH (maybe base all on twisted?)
- * making the SMTP outbox as convenient to use as ``django.core.mail.outbox``
- * add your own here!
-
- ----
-
- .. [1] The idea for this project was born when I needed to check that `a piece
- of software`_ behaved itself when receiving HTTP error codes 404 and 500.
- Having unsuccessfully tried to mock a server, I stumbled across
- `linkchecker`_ which uses a the same idea to test its internals.
-
- .. _monkeypatching: http://pytest.org/latest/monkeypatch.html
- .. _pytest: http://pytest.org/
- .. _funcargs feature: http://pytest.org/latest/funcargs.html
- .. _linkchecker: http://linkchecker.sourceforge.net/
- .. _WSGI application: http://www.python.org/dev/peps/pep-0333/
- .. _PyPI: http://pypi.python.org/pypi/pytest-localserver/
- .. _bleeding-edge archive: https://bitbucket.org/basti/pytest-localserver/get/tip.tar.gz
- .. _report: https://bitbucket.org/basti/pytest-localserver/issues/
- .. _tox: http://testrun.org/tox/
- .. _a piece of software: http://pypi.python.org/pypi/python-amazon-product-api/
- .. _Mailsink recipe: http://code.activestate.com/recipes/440690/
- .. _Sebastien Martini: http://code.activestate.com/recipes/442473/
-
-Keywords: py.test pytest server localhost http smtp
-Platform: UNKNOWN
-Classifier: Operating System :: OS Independent
-Classifier: Development Status :: 4 - Beta
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Topic :: Software Development :: Testing
+Metadata-Version: 1.1
+Name: pytest-localserver
+Version: 0.3.5
+Summary: py.test plugin to test server connections locally.
+Home-page: http://bitbucket.org/basti/pytest-localserver/
+Author: Sebastian Rahlf
+Author-email: basti AT redtoad DOT de
+License: MIT License
+Download-URL: http://bitbucket.org/basti/pytest-localserver/downloads/
+Description: ==================
+ pytest-localserver
+ ==================
+
+ pytest-localserver is a plugin for the `pytest`_ testing framework which enables
+ you to test server connections locally.
+
+ Sometimes `monkeypatching`_ ``urllib2.urlopen()`` just does not cut it, for
+ instance if you work with ``urllib2.Request``, define your own openers/handlers
+ or work with ``httplib``. In these cases it may come in handy to have an HTTP
+ server running locally which behaves just like the real thing [1]_. Well, look
+ no further!
+
+ Quickstart
+ ==========
+
+ Let's say you have a function to scrape HTML which only required to be pointed
+ at a URL ::
+
+ import requests
+ def scrape(url):
+ html = requests.get(url).text
+ # some parsing happens here
+ # ...
+ return result
+
+ You want to test this function in its entirety without having to rely on a
+ remote server whose content you cannot control, neither do you want to waste
+ time setting up a complex mechanism to mock or patch the underlying Python
+ modules dealing with the actual HTTP request (of which there are more than one
+ BTW). So what do you do?
+
+ You simply use pytest's `funcargs feature`_ and simulate an entire server
+ locally! ::
+
+ def test_retrieve_some_content(httpserver):
+ httpserver.serve_content(open('cached-content.html').read())
+ assert scrape(httpserver.url) == 'Found it!'
+
+ What happened here is that for the duration of your tests an HTTP server is
+ started on a random port on localhost which will serve the content you tell it
+ to and behaves just like the real thing.
+
+ The added bonus is that you can test whether your code behaves gracefully if
+ there is a network problem::
+
+ def test_content_retrieval_fails_graciously(httpserver):
+ httpserver.serve_content('File not found!', 404)
+ pytest.raises(ContentNotFoundException, scrape, httpserver.url)
+
+ The same thing works for SMTP servers, too::
+
+ def test_sending_some_message(smtpserver):
+ mailer = MyMailer(host=smtpserver.addr[0], port=smtpserver.addr[1])
+ mailer.send(to='bob at example.com', from_='alice at example.com',
+ subject='MyMailer v1.0', body='Check out my mailer!')
+ assert len(smtpserver.outbox)==1
+
+ Here an SMTP server is started which accepts e-mails being sent to it. The
+ nice feature here is that you can actually check if the message was received
+ and what was sent by looking into the smtpserver's ``outbox``.
+
+ It is really that easy!
+
+ Available funcargs
+ ==================
+
+ Here is a short overview of the available funcargs. For more details I suggest
+ poking around in the code itself.
+
+ ``httpserver``
+ provides a threaded HTTP server instance running on localhost. It has the
+ following attributes:
+
+ * ``code`` - HTTP response code (int)
+ * ``content`` - content of next response (str)
+ * ``headers`` - response headers (dict)
+
+ Once these attribute are set, all subsequent requests will be answered with
+ these values until they are changed or the server is stopped. A more
+ convenient way to change these is ::
+
+ httpserver.serve_content(content=None, code=200, headers=None)
+
+ The server address can be found in property
+
+ * ``url``
+
+ which is the string representation of tuple ``server_address`` (host as str,
+ port as int).
+
+ If you want to check which form fields have been POSTed, Try ::
+
+ httpserver.serve_content(..., show_post_vars=True)
+
+ which will display them as parsable text.
+
+ ``httpsserver``
+ is the same as ``httpserver`` only with SSL encryption.
+
+ ``smtpserver``
+ provides a threaded instance of ``smtpd.SMTPServer`` runnning on localhost.
+ It has the following attributes:
+
+ * ``addr`` - server address as tuple (host as str, port as int)
+ * ``outbox`` - list of ``email.message.Message`` instances received.
+
+ Using your a WSGI application as test server
+ ============================================
+
+ As of version 0.3 you can now use a `WSGI application`_ to run on the test
+ server ::
+
+ from pytest_localserver.http import WSGIServer
+
+ def simple_app(environ, start_response):
+ """Simplest possible WSGI application"""
+ status = '200 OK'
+ response_headers = [('Content-type', 'text/plain')]
+ start_response(status, response_headers)
+ return ['Hello world!\n']
+
+ def pytest_funcarg__testserver(request):
+ """Defines the testserver funcarg"""
+ server = WSGIServer(application=simple_app)
+ server.start()
+ request.addfinalizer(server.stop)
+ return server
+
+ def test_retrieve_some_content(testserver):
+ assert scrape(testserver.url) == 'Hello world!\n'
+
+ Have a look at the following page for more information on WSGI:
+ http://wsgi.readthedocs.org/en/latest/learn.html
+
+ Download and Installation
+ =========================
+
+ You can install the plugin by running ::
+
+ pip install pytest-localserver
+
+ Alternatively, get the latest stable version from `PyPI`_ or the latest
+ `bleeding-edge archive`_ from bitbucket.org.
+
+ License and Credits
+ ===================
+
+ This plugin is released under the MIT license. You can find the full text of
+ the license in the LICENSE file.
+
+ Copyright (C) 2010-2013 Sebastian Rahlf and others (see AUTHORS).
+
+ Some parts of this package is based on ideas or code from other people:
+
+ - I borrowed some implementation ideas for the httpserver from `linkchecker`_.
+ - The implementation for the SMTP server is based on the `Mailsink recipe`_ by
+ Adam Feuer, Matt Branthwaite and Troy Frever.
+ - The HTTPS implementation is based on work by `Sebastien Martini`_.
+
+ Thanks guys!
+
+ Development and future plans
+ ============================
+
+ Feel free to clone the repository and add your own changes. Pull requests are
+ always welcome!::
+
+ hg clone https://bitbucket.org/basti/pytest-localserver
+
+ If you find any bugs, please file a `report`_.
+
+ Test can be run with tox. Note that you need virtualenv<1.8 to run tests for
+ Python 2.4.
+
+ I already have a couple of ideas for future versions:
+
+ * support for FTP, SSH (maybe base all on twisted?)
+ * making the SMTP outbox as convenient to use as ``django.core.mail.outbox``
+ * add your own here!
+
+ ----
+
+ .. [1] The idea for this project was born when I needed to check that `a piece
+ of software`_ behaved itself when receiving HTTP error codes 404 and 500.
+ Having unsuccessfully tried to mock a server, I stumbled across
+ `linkchecker`_ which uses a the same idea to test its internals.
+
+ .. _monkeypatching: http://pytest.org/latest/monkeypatch.html
+ .. _pytest: http://pytest.org/
+ .. _funcargs feature: http://pytest.org/latest/funcargs.html
+ .. _linkchecker: http://linkchecker.sourceforge.net/
+ .. _WSGI application: http://www.python.org/dev/peps/pep-0333/
+ .. _PyPI: http://pypi.python.org/pypi/pytest-localserver/
+ .. _bleeding-edge archive: https://bitbucket.org/basti/pytest-localserver/get/tip.tar.gz
+ .. _report: https://bitbucket.org/basti/pytest-localserver/issues/
+ .. _tox: http://testrun.org/tox/
+ .. _a piece of software: http://pypi.python.org/pypi/python-amazon-product-api/
+ .. _Mailsink recipe: http://code.activestate.com/recipes/440690/
+ .. _Sebastien Martini: http://code.activestate.com/recipes/442473/
+
+Keywords: py.test pytest server localhost http smtp
+Platform: UNKNOWN
+Classifier: Operating System :: OS Independent
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Software Development :: Testing
diff --git a/pytest_localserver.egg-info/SOURCES.txt b/pytest_localserver.egg-info/SOURCES.txt
index 0f64ed0..eb237c5 100644
--- a/pytest_localserver.egg-info/SOURCES.txt
+++ b/pytest_localserver.egg-info/SOURCES.txt
@@ -8,7 +8,9 @@ pytest_localserver/ca.crt
pytest_localserver/http.py
pytest_localserver/https.py
pytest_localserver/plugin.py
+pytest_localserver/server.csr
pytest_localserver/server.pem
+pytest_localserver/server.pem.orig
pytest_localserver/smtp.py
pytest_localserver.egg-info/PKG-INFO
pytest_localserver.egg-info/SOURCES.txt
diff --git a/pytest_localserver.egg-info/requires.txt b/pytest_localserver.egg-info/requires.txt
index e41be49..9791813 100644
--- a/pytest_localserver.egg-info/requires.txt
+++ b/pytest_localserver.egg-info/requires.txt
@@ -1 +1 @@
-werkzeug>=0.10
\ No newline at end of file
+werkzeug>=0.10
diff --git a/pytest_localserver/__init__.py b/pytest_localserver/__init__.py
index 46df43f..c3e0bec 100644
--- a/pytest_localserver/__init__.py
+++ b/pytest_localserver/__init__.py
@@ -1 +1 @@
-VERSION = '0.3.4'
+VERSION = '0.3.5'
diff --git a/pytest_localserver/server.csr b/pytest_localserver/server.csr
new file mode 100644
index 0000000..68f5ca5
--- /dev/null
+++ b/pytest_localserver/server.csr
@@ -0,0 +1,28 @@
+-----BEGIN CERTIFICATE REQUEST-----
+MIIEsDCCApgCAQAwazELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
+GzAZBgNVBAoMEnB5dGVzdC1sb2NhbHNlcnZlcjEWMBQGA1UECwwNVGVzdGluZyBE
+ZXB0LjESMBAGA1UEAwwJMTI3LjAuMC4xMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
+MIICCgKCAgEAv3Tux8Ca22wL+VC7eA0jeSJoqNg7TgOf3gIr8vq+WRV+lV/Kvawn
++Pmv88JLIzZX+wkK8uNoFhBVxApVhA9rZ1xeu81mu9Ux2LPCoKti73SAbf93Xu4v
+QfcIOSYz438a1TymRi3I6AVSUW+YWl1V8dAsVKbKaPDdPPP4oMUSq92YvI2kBQ0S
+DnzHezRpd8zh3edYG5BPpkZCTXU+lbegh9ihjzoWVzGoY9NPGOk3FBDU/AAVawmJ
+Hbb6aTZz5K61fe9AY+KGl632iPSqo54YwMF/avZge/CFh40owEIu4Ow9DNpbcGm/
+kOsvvlu1T9ttlPA3kxjEAUwsSAvbdSjCVTJihef4COu5/vG5wv/MV2e5dO7S7qo9
+nZpN7GNPXn50wW7vAZXAX1D6EIBO7tpjW44GIDR7+sdlzcaEHXL+zcNWKBKimDov
+QFQ0YEPxjO8H78FSGvWAHIzOMPx84c1TLhETDLn+IQoh0pdFYTdPkDKR+CTpQH9n
+gaA6banol0B+c8/Tk0odvphv8DWlsEYK1H8o0+4EjhO7X77XX5dOApScUFulZh7U
+1Qt+zqyYsUaBVX4uLIUo1wMz/lJfM4aYEwG0DwKMFzNmv6LQwMRIThurdmCRj4lv
+JltpKx6Z88Wmx2eu6Tb4tQQoBQxnKdcmsDpcU13xFYOkJbzq6BZFqlcCAwEAAaAA
+MA0GCSqGSIb3DQEBBQUAA4ICAQCs2Dl8wRY2KLRO/2DVhKC/Vo3Zj80edRdy5zh0
+SVg1PTOgMFJ+ZTC2nuDCUjT33LcaTSZ84Hzn+IMMxqDagXTXZL4r/VPlVdSWiM4V
+DAz5L3PRkvE+/qi5vDgM6Udq5E5wUHvRVGAl0fnVbH08sCk8l9tfImCT2J/DCvTn
+bMfipsQFBAos9/0OghMAas8qinYvR9QgBA8yqrsai95epP/Lkp+vdj2JBRyE2l/H
+LCkqNkMNau5I4sTh3gZryq6IvC/OZlWvWFhedvvMW9Z7xAUIVB/pwAdgE0bkCUoW
+oiBwYu+nVosI0Wp7yVA/1IYtOjvt+6HO1CU/KmOD4AjhvQaMlPZIlbOrk+9osWPI
+N7m4d89q46oV9mI8wfxsbwTlXnDfn9T85nDHn61FvnD+GV1zGx8Cfc5Ez1f0RUL6
+7LBBevXPC1EdUaQpYG0oxmhVJdRBkEYNcrN+J34TqlMX1D1LUgRUrQGC59ERn8O0
+kPkiExmt970ymXN1xxkX6u8XM+VRmBeDDda8VVPz+FrK9ddaIPaoMcSiXOTZqMg3
+ZDP/wlzkLrEffegHcitOzeNuZGzy4A2DwNyYHKyBe6wAlInX5TKF0VoLzJ0FyB2T
+qYlW1Yc7IHe0tMMG8+jC7Mo1teyKCHNYDum49kOmuuPENPztbXovI6N7ROgRgfcK
+UeWiig==
+-----END CERTIFICATE REQUEST-----
diff --git a/pytest_localserver/server.pem.orig b/pytest_localserver/server.pem.orig
new file mode 100644
index 0000000..483d3f1
--- /dev/null
+++ b/pytest_localserver/server.pem.orig
@@ -0,0 +1,81 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKAIBAAKCAgEA0phLUETPqoTk32D857Cg1HHtpp07IR34uz5/Vnw+5HNG+51u
+LQCrRktVySyfDGhJTVTv+Ysx3+g4Fq0uU/sYvaZSoZSziH7LetoWpYuU34QAMFTg
+8Pk7Tli1axUJz0G5pO6ClUf9i25pFS8/lbk335d4MGc6w//+pthpuhzan8PaufP1
+DOVQPIcvrsDjZI1/yb0zBKTYKPaRGoTrM2lgX3BKVApSAq1fL8NYzBx9vR3Fwo/5
+sRPRWl9BpQNxv6zDYV2CtrfK9D1opxZulTi45r0aPcVqY1tY79ZdXoO+0dVVJSnE
+WH3RmCDKS229Sg6wTZp+qIHw8WTkAXxX7Wg7wHp5l7Ml7gnoM00pzEvk1ZwPnzyX
+ai0R3ADhhmJx3nDUNx+3QmQ+miFD1brn1W+oUf//Wylx2zP5numWVrXuwvPoHUez
+dJwHXpIAYxByG8RhER/OB7J45lFgwQPEYpkATP3LMZNc19K6jqp70HTgW+3ICTWC
... 146 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pytest-localserver.git
More information about the Python-modules-commits
mailing list