top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Convert Python 3 ResourceWarnings into exception

0 votes
295 views

Is there "a way to force a Python 3 unittest to fail, rather than simply print a warning to stderr, if it causes any ResourceWarning?"

posted Jul 30, 2014 by Gurminder

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

python -W error ...
"Raise an exception instead of printing a warning message."

You can also turn this on with the warnings module. Assuming that this works for ResourceWarning, which is should, please correct the SO record.

answer Jul 30, 2014 by Tarun Singhal
Similar Questions
+2 votes
import json,httplib,urllib
connection = httplib.HTTPSConnection('api.parse.com', 443)
params =
urllib.urlencode({"username":"cooldude6","password":"p_n7!-e8"})
connection.connect()
connection.request('GET', '/1/login?%s' % params, '', {
 "X-Parse-Application-Id": "${APPLICATION_ID}",
 "X-Parse-REST-API-Key": "${REST_API_KEY}",
 "X-Parse-Revocable-Session": "1"
 })
result = json.loads(connection.getresponse().read())
print result

I need ruby equivalent code for this python script

+2 votes

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

 >>> binary
 array([ 1., 0., 1., 0.])

I wish the array to be in the form 1010, so it can be manipulated. I do not want to use built in binary converters as I am trying to build my own.

...