betamaxpy / betamax_matchers Goto Github PK
View Code? Open in Web Editor NEWA group of experimental matchers for Betamax
License: Other
A group of experimental matchers for Betamax
License: Other
I'm trying to use the awesome MultipartFormDataBodyMatcher you recently wrote and am running into some issues.
On the line request.body.encode('utf-8')
, I receive a AttributeError: 'bytes' object has no attribute 'encode'
in python3.4 when attempting to match the existing cassette. In python 2.7 the matching exception is UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 615: ordinal not in range(128)
. On py 2.7 the following deprecation warning is emitted (I'm not sure of its source):
/Users/bboe/.venv/p27/lib/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/packages/urllib3/contrib/pyopenssl.py:198: DeprecationWarning: unicode for buf is no longer accepted, use bytes
Below is the request that is saved in the cassette:
{
"recorded_at": "2015-06-25T06:38:06",
"request": {
"body": {
"encoding": "utf-8",
"string": "--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"img_type\"\r\n\r\njpg\r\n--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"header\"\r\n\r\n1\r\n--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"r\"\r\n\r\nreddit_api_test\r\n--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"uh\"\r\n\r\nr7blffd0gne125077e056d9ac6f04a24a9ce130f8da0657878\r\n--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"api_type\"\r\n\r\njson\r\n--e3f99acd801b4505a9e9badc8ca979a9\r\nContent-Disposition: form-data; name=\"file\"; filename=\"white-square.jpg\"\r\n\r\n\ufffd\ufffd\ufffd\ufffd\u0000\u0010JFIF\u0000\u0001\u0001\u0001\u0000H\u0000H\u0000\u0000\ufffd\ufffd\u0000C\u0000\u0006\u0004\u0005\u0006\u0005\u0004\u0006\u0006\u0005\u0006\u0007\u0007\u0006\b\n\u0010\n\n\t\t\n\u0014\u000e\u000f\f\u0010\u0017\u0014\u0018\u0018\u0017\u0014\u0016\u0016\u001a\u001d%\u001f\u001a\u001b#\u001c\u0016\u0016 , #&')*)\u0019\u001f-0-(0%()(\ufffd\ufffd\u0000\u000b\b\u0001,\u0001,\u0001\u0001\u0011\u0000\ufffd\ufffd\u0000\u0015\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\b\ufffd\ufffd\u0000\u0014\u0010\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ufffd\ufffd\u0000\b\u0001\u0001\u0000\u0000?\u0000\ufffd@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u007f\ufffd\ufffd\r\n--e3f99acd801b4505a9e9badc8ca979a9--\r\n"
},
"headers": {
"Accept": [
"*/*"
],
"Accept-Encoding": [
"gzip, deflate"
],
"Connection": [
"keep-alive"
],
"Content-Length": [
"1177"
],
"Content-Type": [
"multipart/form-data; boundary=e3f99acd801b4505a9e9badc8ca979a9"
],
"Cookie": [
"reddit_session=OMITTED"
],
"User-Agent": [
"PRAW_test_suite PRAW/3.0.0 Python/2.7.9 Darwin-14.3.0-x86_64-i386-64bit"
]
},
"method": "POST",
"uri": "https://api.reddit.com/api/upload_sr_img"
},
"response": {
"body": {
"base64_string": "H4sIAAAAAAAAA6pWSi0qyi8qVrJSiI7VUVDKzE2PLy5KVrJSUMooKSmw0tdP0ivJKM1NKtYrSk1JySzJTU3JTNRLzs/VN3Q38TVKD4jPDNANMiuK8vNNKfePzywu9fP0TIwv9a8ydPY0dIzKNogvSNbLKkhXqgUAAAD//wMAMIJgGWwAAAA=",
"encoding": "UTF-8"
},
"headers": {
"cache-control": [
"private, no-cache",
"no-cache"
],
"cf-ray": [
"1fbeaae279190d97-SJC"
],
"connection": [
"keep-alive"
],
"content-encoding": [
"gzip"
],
"content-type": [
"application/json; charset=UTF-8"
],
"date": [
"Thu, 25 Jun 2015 06:38:05 GMT"
],
"pragma": [
"no-cache"
],
"server": [
"cloudflare-nginx"
],
"transfer-encoding": [
"chunked"
],
"x-content-type-options": [
"nosniff"
],
"x-frame-options": [
"SAMEORIGIN"
],
"x-moose": [
"majestic"
],
"x-ratelimit-remaining": [
"292"
],
"x-ratelimit-reset": [
"115"
],
"x-ratelimit-used": [
"8"
],
"x-ua-compatible": [
"IE=edge"
],
"x-xss-protection": [
"1; mode=block"
]
},
"status": {
"code": 200,
"message": "OK"
},
"url": "https://api.reddit.com/api/upload_sr_img"
}
I was running github actions on a package that uses Betamax-matchers for testing, but when the VM tried to install betamax on python 3.8 on windows, I got this error:
Searching for betamax-matchers<0.5,>=0.3.0
Reading https://pypi.org/simple/betamax-matchers/
Downloading https://files.pythonhosted.org/packages/7e/31/71e2badb382bddd7521f2c2effaac7b2de01ae25b816b02459c2986aef0e/betamax-matchers-0.4.0.tar.gz#sha256=83609d39ac25a7eed8ad3bec426cd15e647c89b4f0f1583ec44a4481bde4171f
Best match: betamax-matchers 0.4.0
Processing betamax-matchers-0.4.0.tar.gz
Writing C:\Users\RUNNER~1\AppData\Local\Temp\easy_install-vfbopexq\betamax-matchers-0.4.0\setup.cfg
Running betamax-matchers-0.4.0\setup.py -q bdist_egg --dist-dir C:\Users\RUNNER~1\AppData\Local\Temp\easy_install-vfbopexq\betamax-matchers-0.4.0\egg-dist-tmp-u0cy_lb3
warning: manifest_maker: MANIFEST.in, line 5: 'recursive-include' expects <dir> <pattern1> <pattern2> ...
warning: manifest_maker: MANIFEST.in, line 6: 'recursive-include' expects <dir> <pattern1> <pattern2> ...
no previously-included directories found matching '*.pyc'
no previously-included directories found matching 'docs\_build'
error: Setup script exited with error: SandboxViolation: mkdir('C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\easy_install-vfbopexq\\betamax-matchers-0.4.0\\build', 511) {}
The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
I'm filing this here because the exception appears to originate from the JSONBodyMatcher. I admit I haven't spent a ton of time digging into the issue; I simply want to write down the current progress, and hope that maybe someone else has encountered something similar.
This test just started failing on travis.
https://travis-ci.org/praw-dev/prawcore/jobs/150672131#L376
Aside from inconsequential changes I've made to the package, the major change was the release of requests 2.11.0: http://docs.python-requests.org/en/master/community/updates/#id1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.