top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

python - nose config

0 votes

I'm using nose to generate and run some tests not for python code, but for an html repository. I know this isn't the typical way to use nose, and so I'm asking here if the following code smells wrong.

I pass some args with the testconfig plugin and run a class setup method one time to get some information from a database. Then the tests get generated and run. During the run, a database is updated with the result. That is an intentional side-effect of running the that okay or something that should never be done?

I've shortened the actual code to make it readable, but the main thing is the setup (setting class vars), the test generator, and the actual test (plus the database update):

class HtmlTester(object):
 Run this setup method once before tests begin.
 Reads from tconfig args to get document from database.
 def setup_class(cls):
 name = tconfig['name']
 language = tconfig.get('language', 'en')
 report = db.conn({'name':name, 

 def test_images(self):
 for image in['images']:
 yield (self.check_image, image)

 def check_image(self, image):
 True if image can be read, otherwise False
 r = False
 if get_imagesize(image):
 p = ImageFile.Parser()
 except IOError:
 r = False
 r = True{'image':image, 'result':r, 
 'language': self.language})

 if __name__ == '__main__':
 args = sys.argv[:1] + ['--tc=name:mybook', 
 '--tc=language:en' ] + sys.argv[1:]

This is complex enough that I wonder if the above approach is correct.

posted Aug 15, 2013 by Deepak Dasgupta

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
0 votes

i want to sent a response for my form submit from server to client, that means python flask to javascript. My javascript code is given follows

document.addEventListener('DOMContentLoaded', function() {

chrome.tabs.getSelected(null, function(tab) {
  d = document;
  var f = d.createElement('form');
  f.action = '';
  f.method = 'post';
  var i = d.createElement('input');
  i.type = 'hidden'; = 'url';
  i.value = tab.url;
    request = new XMLHttpRequest();"POST","",true);
    request.addEventListener("readystatechange", processRequest,false);
    function processRequest(e)
    if(request.readyState==4 && request.status == 200)
    var response = JSON.parse(request.responseText);

And my Python server code is follows

from flask import Flask, flash, redirect, url_for, request, render_template,jsonify
import json
import UrlTest
import trainingSet as ts

app = Flask(__name__)

@app.route('/Get Form/',methods = ['POST'])
def GetForm():
request.method == 'POST'
print s
return str(s)

@app.route('/PutValue/',methods = ['POST'])
def PutValue():
request.method == 'POST'
print s
return jsonify(result=s)

if (__name__ == '__main__'):,host='', use_reloader=False)

I want to send the value of s to the javascript client. please help me to send this the value of s.
and if u can suggest the complete code in javascipt and python

+1 vote

i want to create a chrome extension. its have complex mathematical queries. so i need to use python as scripting language. help me to implement python script in google chrome addon

+1 vote

I would like to create AWS monthly billing graph using python and python for this i need python script using that i have to get last 6 month's monthly bill in AWS.

For this, I have created one virtual environment in my local machine. for example my ip is: Here after pull that script, it's automatically connected to AWS and display's last 6 month's data. its my requirement.

Useful Links with Similar Problem
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.