473,626 Members | 3,392 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 "customizat ion 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
reStructuredTex t.

--
~*~*~*~*~*~*~*~ *~*~*~*~*~*~*~* ~*~*~
Runsun Pan, PhD
py********@gmai l.com
Nat'l Center for Macromolecular Imaging
http://ncmi.bcm.tmc.edu/ncmi/
~*~*~*~*~*~*~*~ *~*~*~*~*~*~*~* ~*~*~
Feb 2 '06 #1
1 1244
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
1857
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 product, category, news etc. - often i have fex. load, request, insert, update and delete functions for them - often problems are the same ones: - which member variables are expected from the form, which ones are not
4
2123
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
1844
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
1509
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 understanding, but I think, it should be achieved somehow.
2
1377
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 InnerClass_B : public InnerClass_A { .... }; class Main
3
1858
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 typeid can access private methods of typeinfo class. Can some one list me the exact declaration of typeid and typeinfo class if they have right away ?
3
1736
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 the tool that can watch this? Thanks. Regards, Tsung-Yu
0
726
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 class level variables. Thanks, Mike Ober
1
3606
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
1527
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 not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:
0
8262
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.