![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
unittest for every module
All right, you win. Ruby is fun, but I'm finding through use that Python is more scalable, clean, and more suited to readability. Unfortunately, it seems to me that the trend in the Ruby community is to encourage golf and one-liners, much like Perl. In Ruby's defence, it still has a much more pure design that is more thought-out then Python.
Anyway, back to the main point of this thread. To my delight, python comes with a unit test framework. It's not as good as Ruby's, but it's still useful. My idea was to create a bunch of unit tests for every module like so: python Syntax (Toggle Plain Text)
My questions are: a) Is this a good idea? and b) Should I create the class and run the tests under the if condition, or create some kind of main() method that's called under the if __name__.. etc thing?
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! Last edited by Jessehk; Jul 21st, 2006 at 1:11 PM. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Sure, it's a good idea, so long as you don't have your unit tests in the same module as your code.
The unit tests for my modules tend to look something like: python Syntax (Toggle Plain Text)
I also agree with you about Ruby. I like the way it handles properties and classes, but dislike the Perl hackiness (if there is such a word) that pervades the language. |
|
|
|
|
|
#3 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
So I guess you'd have something like:
/app |____/lib |____/test |____/bin ? In that case, if I was in /test, and I wanted to import a module in another directory, would I just append to sys.path ? EDIT: Oh, and thanks. I'll have to look into py.test. ![]()
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4
![]() |
You might want to look into Nose; it's the unit testing framework used by Turbogears.
__________________
:wq |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Update a Module | Dietrich | Python | 2 | Apr 29th, 2006 2:19 PM |
| C++ OWL What am I doing wrong | Vagabond | C++ | 7 | Mar 24th, 2006 6:31 PM |
| cgi module index.py?var=x how do i retrieve this w/o os module | cypherkronis | Python | 1 | Jul 3rd, 2005 2:10 PM |
| Numeric module | Dietrich | Python | 2 | Apr 5th, 2005 2:37 AM |
| word wrap in module window? | chepfaust | Visual Basic | 2 | Mar 17th, 2005 8:03 PM |