Skip to content

Commit 45812f4

Browse files
author
derwentx
committed
added tox config and better error handling
1 parent 557be23 commit 45812f4

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ run.py
88
run3.py
99
*.orig
1010
.eggs/*
11-
.cache/v/cache/lastfailed
12-
pylint_report.txt
11+
.cache/v/cache/lastfailed
12+
pylint_report.txt
1313
.pypirc
14+
.tox/*
15+
.pytest_cache/*

tests.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,15 +1001,15 @@ def test_APIGet(self):
10011001
response_obj = response.json()
10021002
self.assertEqual(response_obj['name'], self.api_params['wp_user'])
10031003

1004-
class WPAPITestCasesBasic(WPAPITestCasesBase):
1005-
def setUp(self):
1006-
super(WPAPITestCasesBasic, self).setUp()
1007-
self.api_params.update({
1008-
'user_auth': True,
1009-
'basic_auth': True,
1010-
'query_string_auth': False,
1011-
})
1012-
self.wpapi = API(**self.api_params)
1004+
# class WPAPITestCasesBasic(WPAPITestCasesBase):
1005+
# def setUp(self):
1006+
# super(WPAPITestCasesBasic, self).setUp()
1007+
# self.api_params.update({
1008+
# 'user_auth': True,
1009+
# 'basic_auth': True,
1010+
# 'query_string_auth': False,
1011+
# })
1012+
# self.wpapi = API(**self.api_params)
10131013

10141014
# class WPAPITestCasesBasicV1(WPAPITestCasesBase):
10151015
# def setUp(self):

tox.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Tox (https://tox.readthedocs.io/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
envlist = py27, py36
8+
9+
[testenv]
10+
deps=
11+
-rrequirements.txt
12+
-rrequirements-test.txt
13+
commands=
14+
pytest

wordpress/api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# from requests import request
1010
import logging
11+
from six import text_type, u
1112
from json import dumps as jsonencode
1213

1314
from wordpress.auth import BasicAuth, OAuth, OAuth_3Leg
@@ -164,12 +165,12 @@ def request_post_mortem(self, response=None):
164165
header_url = StrUtils.eviscerate(header_url, '/')
165166
remedy = "try changing url to %s" % header_url
166167

167-
msg = "API call to %s returned \nCODE: %s\nRESPONSE:%s \nHEADERS: %s\nREQ_BODY:%s" % (
168+
msg = u"API call to %s returned \nCODE: %s\nRESPONSE:%s \nHEADERS: %s\nREQ_BODY:%s" % (
168169
request_url,
169-
str(response.status_code),
170+
text_type(response.status_code),
170171
UrlUtils.beautify_response(response),
171-
str(response_headers),
172-
str(request_body)[:1000]
172+
text_type(response_headers),
173+
repr(request_body)[:1000]
173174
)
174175
if reason:
175176
msg += "\nBecause of %s" % reason

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy