Commit Graph

180 Commits

Author SHA1 Message Date
Chris Dent 0a84775971 Release 1.5.0
* accept empty strings from app iterator
* start testing with python 3.6
* ssl fixes for httplib2
2017-03-06 17:44:00 +00:00
Chris Dent e9a75da901 Merge pull request #47 from cdent/fix-46
Accept an empty string from a wsgi iterator
2017-03-06 17:40:59 +00:00
Chris Dent 66e2d50000 Accept an empty string from a wsgi iterator
This is allowed by the pep but the code was written such that if it
received an empty string it would not get the rest of the iterator.
This change fixes it so only None will cause the stop.

With this change an unrelated test wsgi app which was returning an
empty string needed to be fixed to return a bytestring.

Fixes #46
2017-03-05 15:02:50 +00:00
Chris Dent 21276926ff add testing for py36 2017-03-05 14:07:08 +00:00
Chris Dent 17ea1a79bf Add another ssl-related keyword to the httplib2 intercept
Should probably consider changing it to kwargs, but this way it is
explicit about what args are being dropped. Add a note to the docs
to indicate this is the case (it's always been true).
2017-03-05 13:58:25 +00:00
Chris Dent 4d3901a5bc Fix packaging and use of README file 2016-09-27 10:55:45 +01:00
Chris Dent 7a0851f738 Merge pull request #45 from cdent/response-header-check
Response header check
2016-09-27 10:44:02 +01:00
Chris Dent ac5f41a03e remove no longer used __version__ 2016-09-27 10:31:37 +01:00
Chris Dent f731f862af Fix pep8 errors in doc string
And update to the resulting README
2016-09-27 10:26:34 +01:00
Chris Dent 80ec54e182 update readme 2016-09-27 10:26:33 +01:00
Chris Dent 0b4abf152b Correct the bytes v str problem
Headers should be native str.

Add some docs about that and format the existing docs around that
area to be a bit more readable.
2016-09-27 10:26:33 +01:00
Chris Dent 8dfb78162b Fix up README and version handling
With the addition of six to __init__.py the import of wsgi_intercept
in setup.py to get version and long description information no longer
works. Now we keep that information externally:

* version is static in setup.py
* the __doc__ from __init__.py is written to README.rst by a tox
  target, and that is loaded by setup.py

This has an added benefit of keeping the github visible readme,
the pypi info, and the main docs all in sync, at the cost of a
little magic. The __doc__ rarely changes, so the magic isn't
that bad.

Note that the bug in this code (the use of bytestrings) is not
yet fixed, but I'm making this change on that branch because it
makes the test usable.
2016-09-27 10:26:33 +01:00
Chris Dent 34eb63940d Add a global flag to strictly handle response headers
According to pep 3333 response headers are supposed to be
bytestrings. In Python 2 that means a str, and in Python 3, bytes.
Some wsgi servers, notably mod_wsgi, check that the values of
headers are correct, and make an error if they are not.

In at least some testing situations wsgi-intercept should
replicate this behavior so that an application can know that
it is not sending bad headers.

This is something that needs to be done in wsgi_intercept itself,
and not external tests, because many http client libraries will
transform response header values to native strings before providing
them to the caller.

However, many existing tools (for example selector) do not obey
this constraint, so we cannot simply turn this check on by default.
Instead we need to be able to declare that for a given context
we want it to be done. The easiest way to do this is to set a module
level global, as done in wsgi_intercept/tests/__init__.py.

In practical terms what this code does, is disallow

* in py2, sending responses with unicode values
* in py3, sending responses with str values

if wsgi_intercept.STRICT_RESPONSE_HEADERS == True.

Because this change introduced some six into
wsgi_intercept/__init__.py, additional changes to use six were made.

Note that since Python 2.7 io.BytesIO has been available so we no
longer need to do a conditional import. Interestingly, some testing
suggests that six.BytesIO in 2.7 is _not_ the same as io.BytesIO.

Fixes: #43
2016-09-27 10:26:28 +01:00
Chris Dent e58af412b6 Merge pull request #44 from cdent/use-tox
Use tox
2016-09-23 12:57:01 +01:00
Chris Dent d197a65ca6 Some cleanups to tox.ini
* Don't usedevelop
* short tracebacks on pytest
* only pep8 in wsgi_intercept
2016-09-23 00:30:22 +01:00
Chris Dent 4f9294ca2a Move tests from the test dir into wsgi_intercept/tests
This helps to insure the tests are included with the package
and to avoid conflicting with other packages.
2016-09-22 20:02:41 +01:00
Chris Dent 2504de1f73 pep8 fixes to get pep8 tox target passing
This is basic flake8 testing without any 'hacking' extensions. We
may wish to add those later, but for the time being this code is
so much of its own particular style that that would be painful.
In any case, the hacking rules aren't that great.

In the process some documentation adjustments were made while fixing
line lenghts. A dead link was removed.
2016-09-22 19:27:01 +01:00
Chris Dent b6ea4bce1b Add testing requirements to docs environment
This avoids noisy warnings when the docs are being built.
2016-09-22 19:04:27 +01:00
Chris Dent 57d6a28b26 Switch to using tox for testing
This allows easier testing of multiple versions of Python in a more
automated fashion. This is needed if we're ever going to make some
of the planned extensive refactorings.

This change:

* adds tox.ini
* updates Makefile and .travis.yml to point to tox
* fixes a doctest typo found while make sure the Makefile targets
  work
* adds a [docs] extras_require so that the deps in tox are managed
  cleanly

The pep8 target is currently commented out because it fails (and
has done for a long time). Will fix asap. This commit is to ensure
that travis is working. Followups will tune it up.
2016-09-22 19:00:13 +01:00
Chris Dent 28f93239cd Release 1.3.2
- fix use of url with no port in interceptor
2016-09-13 16:23:51 +01:00
Chris Dent f1a3c4a69e Merge pull request #42 from cdent/bug/41
Correctly handler a url argument to interceptor with no port
2016-09-13 16:23:28 +01:00
Chris Dent cd1b4927fa Correctly handler a url argument to interceptor with no port
Fixes #41

Without this the split fails when there is no : in netloc.
2016-09-13 16:18:37 +01:00
Chris Dent 1a3ba19722 Release 1.3.1
- docstring fix in example from Cito
2016-07-03 23:23:18 -04:00
Chris Dent 655e9b68eb Merge pull request #40 from Cito/docfix
Small fix in docstring
2016-07-03 23:21:21 -04:00
Christoph Zwerschke 9d0dfb9d57 Small fix in docstring 2016-07-04 00:13:56 +02:00
Chris Dent 677dcdedf2 Release 1.3.0
- Ensure header values in environ are native str
2016-06-29 14:50:54 -04:00
Chris Dent e3ef80c984 Ensure header values are native str
PEP 3333 requires that values in the environ that come from
header be native str objects decoded from ISO-8859-1 bytes.
This means that in Python 2 and 3 they are effectively
different things, but oh well, these are the rules.

One area where this causes a real issue is in the
SimpleCookie.load() method which checks for the type of the
string associated with HTTP_COOKIE.

Fixes #39
2016-06-29 13:53:45 -04:00
Chris Dent d34e64f764 Don't use six when testing httplib
Otherwise monkeypatching get confused and will not work
and the tests will fail. An effort was made to use the
six http_client always (both in tests and the interceptor)
but this led to infinite recursion, so going for the lame
fix here.

The functionality has always worked (as long as six wasn't
involved) this is just getting things working in tests.
2016-06-29 13:49:21 -04:00
Chris Dent 77b5c04a90 make urllib3 min requirement explicit 2016-03-21 16:22:27 +00:00
Chris Dent d7b8d66a0b Release 1.2.1
- better urllib3 error handling
2016-03-18 16:01:49 +00:00
Chris Dent 0bd6442647 Force urllib3 to raise errors immediately
Otherwise it raises the MaxRetryError, masking the real one.
2016-03-18 15:57:03 +00:00
Chris Dent 84d1d4c822 Release 1.2.0
- add support for urllib3
2016-03-18 14:31:37 +00:00
Chris Dent a5aaca3a6f update readme 2016-03-18 14:29:47 +00:00
Chris Dent b746551b5a Merge pull request #38 from cdent/add-urllib3
Add support for intercepting urllib3
2016-03-18 14:28:01 +00:00
Chris Dent 06387f3dda Add urllib3 to the docs
Update the README to reflect the modern condition.
2016-03-18 14:22:21 +00:00
Chris Dent c464f2ec7a Dedupe the urllib3 monkey patching code
requests vendorizes urllib3 which makes monkey patching it while also
wanting to monkey patch proper urllib3 a bit hairy. Here we use a
factory to do the overrides for us. Hat tip to @FND for helping
with the thinking through of this.
2016-03-18 13:43:34 +00:00
Chris Dent 8e02d4e1fe Fix for python3 in use of urllib3.Response.data
Is bytes, we need to cast it to str to do `in`.
2016-03-18 13:24:10 +00:00
Chris Dent 13cd3a4361 add urllib3 to testing requires 2016-03-18 13:11:24 +00:00
Chris Dent fbfbfa3690 Add support for intercepting urllib3
This is relatively straightforward but presents a problem.
The monkeypatching is identical as that for requests, but on
different modules, because of the vendorization of urllib3
that requests does.

It would be better if there was some way to have just one
set of code that removes the duplication and does the right
but maintains the semantics of intercepting the desired thing
by name.
2016-03-18 13:04:44 +00:00
Chris Dent ad07b1c41c Release 1.1.3
- allow network based tests to be skipped in a generic fashion
2016-03-14 15:25:51 +00:00
Chris Dent 767b3c3a37 fix typo in test/README 2016-03-14 15:25:33 +00:00
Chris Dent 0ca206d083 Merge pull request #37 from cdent/skipnetworktests
Skip the network tests if WSGI_INTERCEPT_SKIP_NETWORK
2016-03-14 15:23:02 +00:00
Chris Dent 13c1ea8a01 Skip the network tests if WSGI_INTERCEPT_SKIP_NETWORK
This allows the tests to work in a reasonable way in
network disconnected situations.

Fixes #36
2016-01-27 16:13:06 +00:00
Chris Dent da5f55b29c Release 1.1.2
* clean pyc etc more correct by using the reclean hack
2016-01-27 09:11:34 +00:00
Chris Dent 2f82521042 Release 1.1.1
* Correct packaging errors that included pyc and pyo files.
2016-01-26 18:55:50 +00:00
Chris Dent 16e18ad7db Release 1.1.0
* protect against http_proxy confusing interceptors
* pep8
2016-01-22 14:41:46 +00:00
Chris Dent 05b6772a0a Merge pull request #35 from cdent/issue-30
Guard against http_proxy and https_proxy
2016-01-22 14:33:27 +00:00
Chris Dent 905ef41cb0 Guard against http_proxy and https_proxy
requests and urllib will get upset of socks proxy settings are
present in the environment. In those interceptors, an exception
will now be raised if $http_proxy or $https_proxy are set.

Tests are added to cover the variable being set for all four
of the interceptor types.

This is the quick and dirty solution to the problem. The way this
has been done shows some clear opportunities for refactoring down
the road.

Fixes #30
2016-01-21 19:17:56 +00:00
Chris Dent 3048a09216 Fix rst errors for pypi doc text 2015-12-29 12:58:10 +00:00
Chris Dent 422d7bbaec Release v 1.0.0
* switch to semantic versioning
* provide Interceptor context manager class
2015-12-29 12:04:58 +00:00