سؤال

I'm using gaetestbed in my GAE app, and it's working very well. However, the useful statements that nose prints when your test is incorrect is being washed away by App Engine's logging:

root: Level 9: Evaling filter expression "datastore_types.Key.from_path(u'User', 85, _app=u'tipfy') == datastore_types.Key.from_path(u'User', 87, _app=u'tipfy')"
root: Level 9: Evaling filter expression "datastore_types.Key.from_path(u'User', 87, _app=u'tipfy') == datastore_types.Key.from_path(u'User', 87, _app=u'tipfy')"
root: Level 9: Evaling filter expression "datastore_types.Key.from_path(u'User', 86, _app=u'tipfy') == datastore_types.Key.from_path(u'User', 87, _app=u'tipfy')"
root: Level 9: Evaling filter expression "datastore_types.Key.from_path(u'User', 87, _app=u'tipfy') == datastore_types.Key.from_path(u'User', 87, _app=u'tipfy')"
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 28 tests in 3.605s

Is there a way to suppress this so I can get the clean something != something else error messages only?

هل كانت مفيدة؟

المحلول

Here is a stupid way,

find capture.py and logcapture.py in your nose/plugins/

find function addCaptureToErr in both files, then revise it. (I don't know which one is the right one, please test yourself)

original code should look like this:

def addCaptureToErr(self, ev, output):
    return '\n'.join([str(ev) , ln('>> begin captured stdout <<'),
                      output, ln('>> end captured stdout <<')])

change it into

def addCaptureToErr(self, ev, output):
    check_errmsgs(output)
    return '\n'.join([str(ev) , ln('>> begin captured stdout <<'),
                      output, ln('>> end captured stdout <<')])

def check_errmsgs(self,errmsgs):
    for i in range(len(errmsgs)-1,-1,-1):
        item = errmsgs[i].split(":") 
        if(item[2].find("Evaling filter expression")):
            #find msgs you want to ignore
            del errmsgs[i]

It should works.

نصائح أخرى

Not sure that this will work in gaetestbed, but using django-nose I can add the following to my settings.py:

NOSE_ARGS = ['--logging-clear-handlers', '--logging-filter=-root']

Another work-around is to just inverse grep the output:

./manage.py test 2>&1 | egrep -v "^(root|Level)"

I haven't tried Bigbear's suggestion, but I did find a quick workaround to the problem: pipe the err output into a file.

python run_nosetests.py 2> failures.tmp
gedit failures.tmp &

This allows you to see a clean printout of your errors at the top of the file, and a minimized output of App Engine logging beneath it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top