Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unit testing frameworks

Reply
Thread Tools

Unit testing frameworks

 
 
grkuntzmd@gmail.com
Guest
Posts: n/a
 
      03-24-2009
I am looking for a unit testing framework for Python. I am aware of
nose, but was wondering if there are any others that will
automatically find and run all tests under a directory hierarchy.

Thanks, Ralph
 
Reply With Quote
 
 
 
 
Maxim Khitrov
Guest
Posts: n/a
 
      03-24-2009
On Tue, Mar 24, 2009 at 8:06 AM, <(E-Mail Removed)> wrote:
> I am looking for a unit testing framework for Python. I am aware of
> nose, but was wondering if there are any others that will
> automatically find and run all tests under a directory hierarchy.


Have you already looked at the unittest module? Below is the code I
use for one of my current projects to load all test cases in package.
This code is sitting in __init__.py, and the test cases are in
separate files (util.py, util_threading.py, etc.). Those files can
contain as many TestCase classes as needed, all are loaded with
loadTestsFromModule. You could easily modify this code to
automatically generate the modules list if you want to.

# repo/pypaq/test/__init__.py
from unittest import TestSuite, defaultTestLoader

import logging
import sys

__all__ = ['all_tests']
modules = ['util', 'util_buffer', 'util_event', 'util_threading']

if not __debug__:
raise RuntimeError('test suite must be executed in debug mode')

all_tests = []

for name in modules:
module = __import__('pypaq.test', globals(), locals(), [name], 0)
tests = defaultTestLoader.loadTestsFromModule(getattr(modu le, name))

__all__.append(name)
all_tests.append(tests)
setattr(sys.modules[__name__], name, tests)

logging.getLogger().setLevel(logging.INFO)
all_tests = TestSuite(all_tests)

I then have test_pypaq.py file under repo/, with which I can execute
all_tests or only the tests from a specific module:

# repo/test_pypaq.py
from unittest import TextTestRunner
from pypaq.test import *

TextTestRunner(verbosity=2).run(all_tests)

- Max
 
Reply With Quote
 
 
 
 
pruebauno@latinmail.com
Guest
Posts: n/a
 
      03-24-2009
On Mar 24, 8:06*am, (E-Mail Removed) wrote:
> I am looking for a unit testing framework for Python. I am aware of
> nose, but was wondering if there are any others that will
> automatically find and run all tests under a directory hierarchy.
>
> Thanks, Ralph


*Nose
*Trial
*py.test
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-24-2009
En Tue, 24 Mar 2009 09:06:47 -0300, <(E-Mail Removed)> escribió:

> I am looking for a unit testing framework for Python. I am aware of
> nose, but was wondering if there are any others that will
> automatically find and run all tests under a directory hierarchy.


All known testing tools (and some unknown too):

http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy

--
Gabriel Genellina

 
Reply With Quote
 
Fabio Zadrozny
Guest
Posts: n/a
 
      03-25-2009
Hi Andew,

> not exactly a framework, but useful while working on small projects - you
> can run tests from inside eclipse (using the pydev plugin for python).
> it's easy to run all tests or some small subset (although it is a bit
> buggy for 3.0).


What exactly is not working with 3.0? (couldn't find any related bug
report on that).

Cheers,

Fabio
 
Reply With Quote
 
grkuntzmd@gmail.com
Guest
Posts: n/a
 
      03-25-2009
In unittest, has anyone used the *NIX command "find" to automatically
build a test suite file of all tests under a specified directory?

I generally name my tests as _Test_ORIGINAL_MODULE_NAME.py where
ORIGINAL_MODULE_NAME is the obvious value. This way, I can include/
exclude them from deployments, etc. in my Makefile based on filename
patterns. I was thinking of doing something with "find" to get a list
of test file names and then run them through a Python script to
produce a top-level suite file, probably as the first step in my
Makefile test target.

Any thoughts?
 
Reply With Quote
 
Fabio Zadrozny
Guest
Posts: n/a
 
      03-26-2009
> sorry for not reporting a bug - i assumed you'd know (and the workarounds
> described above meant i wasn't stalled).
>
> i also have eclipse 3.4.2 with pydev 1.4.4.2636 on a separate machine (ie
> new versions), and i can try there if you want (it will take a while to
> get the source there, but is not a problem).


No need... I can probably reproduce it easily here. I've added the bug
report (should be fixed for the next release:
https://sourceforge.net/tracker/?fun...96&atid=577329
)

Cheers,

Fabio
 
Reply With Quote
 
Alexander Draeger
Guest
Posts: n/a
 
      03-29-2009

Hi,

I'm work on a testing framework for Python. Until now I have
implemented the main features of PyUnit and JUnit 4.x. I like the
annotation syntax of JUnit 4.x and it's theory concept is great
therefore you can imagine how my framework will be.

I plan a lot of additionally features which are neither part of Junit
4.5 nor PyUnit. Finding testcases automatically is a good idea.

Alex
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unit-profiling, similar to unit-testing Ulrich Eckhardt Python 6 11-18-2011 02:00 AM
Unit testing errors (testing the platform module) John Maclean Python 1 04-13-2010 02:11 PM
Test::Unit - Ruby Unit Testing Framework Questions Bill Mosteller Ruby 0 10-22-2009 02:02 PM
Unit Testing Without Frameworks Sean O'Dell Ruby 1 07-11-2004 06:24 AM
Unit testing GUI, possible frameworks Phillip Lord Java 0 03-02-2004 12:21 PM



Advertisments