top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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 LinkedIn Share Button

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