473,499 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A class with built-in doctest feature ?

I intend to use the doctect heavily. For this I am thinking of
coding a class that comes with a built-in doctest functionality.
I'd like to seek for input before I start.

The idea is to have a class MyObj from where all my other
classes will subclass.

lets say:

class C(MyObj):
''' This C
(some doctest here) ---- doctest.1
'''
def func1(self):
''' This is C.func1
(some doctest here) --- doctest.2
'''
blah blah blah
return blah

Now, after the above class defintion, I can just do:

C( ).doctest( )

and it will go through doctest.1 and doctest.2 and report the
test results

What is the better way to make such a MyObj ?

The applications of this sort of built-ins are not limited to
a doctest. Similar to the built-in __doc__ that offers some sort
of documentation, a mechnism like what I am proposing can
provide "customization on the fly" feature to allow manipulations
of the doctext at run-time. For example,

C( ).toHtml( )

to convert the __doc__ to a webpage by converting it throu
reStructuredText.

--
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Runsun Pan, PhD
py********@gmail.com
Nat'l Center for Macromolecular Imaging
http://ncmi.bcm.tmc.edu/ncmi/
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Feb 2 '06 #1
1 1233
The idea looks interesting, but you can also design a couple of
functions that scan the docstrings of a given class and its methods to
produce what you need:

doctestAll(C)
toHtml(C)

This is probably simpler and gives similar results.

Bye,
bearophile

Feb 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1849
by: Perttu Pulkkinen | last post by:
Hi all php freaks! Do you think this kind of "property class" is useful or not? I have bee bored to the way I've been coding earlier. because: - often i have database-oriented classes like...
4
2111
by: edg | last post by:
This works: $b = $a->method1(); $c = $b->method2(); I'd like to get this all on one expression, something like: $c = ${$a->method1()}->method2(); which doesn't work.
0
1835
by: angeles | last post by:
I built a junit test class, and want to build multiple test cases using this class by passing different jvmargs. Can anyone tell me how to do this? Thanks!
8
1503
by: Franz Steinhaeusler | last post by:
Hello, (in wxPython) I want to redirect the SetStatusText to an own method (change the text somewhat) and then call the SetStatusText of wx.Frame. But I have a little problem of...
2
1372
by: Ilia Poliakov | last post by:
I have a following class hierarchy, but I dont know if it's right built: //------------------------------ begin of example 1 ------------------------------ class InnerClass_A { .... }; class...
3
1850
by: Ganesh | last post by:
Hi, typeinfo class has a private constructor and only typeid can return object to typeinfo class. So here I am wondering how these two are related. Are these two related through 'friend' so that...
3
1725
by: joye | last post by:
Hello, I can use the tool such as dllexp.exe to watch the export functions which built by unmanagedC++, but I can not watch the export function or class built by managedC++ . Who know where has...
0
718
by: Michael D. Ober | last post by:
Does anyone know of a free or cheap class diagrammer for VB 2005. My requirements are that it go beyond the one built into VS 2005 and show both inheritance and other class dependencies based on...
1
3598
by: teofilo | last post by:
I built this class for simple text based menu, for using with other classes. #ifndef MENU_H #define MENU_H #include <string> using std::string; #include <vector> using std::vector;
1
1523
by: almurph | last post by:
Folks, Hope you can help me with this one. I have a winform which I cannot view in design mode. A ll I can see is a big red "X" and the following following error message: " The designer could...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.