Hi,
I have two strings - a docstring containing doctests and a code string
containing code to be tested with those doctests. I've been trying for
a day now to run the test without concatenating the two strings,
adding:
import doctest
doctest.testmod
to the bottom, writing it all to a file and executing it using popen().
There must be some way of doing this without writing to a temporary
file, any ideas?
thanks in advance,
johannes Woolard 3 1359
notanotheridiot wrote: Hi, I have two strings - a docstring containing doctests and a code string containing code to be tested with those doctests. I've been trying for a day now to run the test without concatenating the two strings, adding:
import doctest doctest.testmod
to the bottom, writing it all to a file and executing it using popen().
There must be some way of doing this without writing to a temporary file, any ideas?
thanks in advance,
johannes Woolard
Create the concatenated string then exec it?
- Pad.
Paddy wrote: notanotheridiot wrote: Hi, I have two strings - a docstring containing doctests and a code string containing code to be tested with those doctests. I've been trying for a day now to run the test without concatenating the two strings, adding:
import doctest doctest.testmod
to the bottom, writing it all to a file and executing it using popen().
There must be some way of doing this without writing to a temporary file, any ideas?
thanks in advance,
johannes Woolard Create the concatenated string then exec it?
I know from experience that this approach does not work. When you do
that, the entire module from which it is run turns out to be scanned
for doctests - not only the string being executed by exec. However, I
understand that Johannes found a solution.
André - Pad.
André wrote: Paddy wrote: notanotheridiot wrote: Hi, I have two strings - a docstring containing doctests and a code string containing code to be tested with those doctests. I've been trying for a day now to run the test without concatenating the two strings, adding:
import doctest doctest.testmod
to the bottom, writing it all to a file and executing it using popen().
There must be some way of doing this without writing to a temporary file, any ideas?
thanks in advance,
johannes Woolard Create the concatenated string then exec it?
I know from experience that this approach does not work. When you do that, the entire module from which it is run turns out to be scanned for doctests - not only the string being executed by exec. However, I understand that Johannes found a solution.
André
- Pad.
Got it, I've blogged about it here: http://pytute.blogspot.com/2006/06/s...ary-files.html
Basically the trick is to pass the docstring ino the exec environment
as a variable and use the advanced doctest api to get a doctest.
Johannes This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pierre Rouleau |
last post by:
I have a problem writing self-testable modules using doctest when these
modules have internationalized strings using gettext _('...').
- The main module of an application (say app.py) calls gettext.install()
to install the special _ function inside Python builtin. Other modules,
taken from a general purpose collection of Python modules, also support
internationalisation and doctest testing.
For example:
|
by: Edward K. Ream |
last post by:
Hi,
I am trying to run the following docstring using docutils.DocTestSuite:
"""
>>> s = "a\n \t\n\t\t \t\nb"
etc...
"""
However, docutils complains about "inconsistent leading whitespace". Well,
|
by: Michele Simionato |
last post by:
Some time ago I hacked a custom solution to run doctests
on text files containing documentation. The solution
involved this kind of game:
tester=doctest.Tester(globs={},verbose=1)
tester.runstring(mytest)
It worked fine, but now with Python 2.4.a3 I get
DeprecationWarning: class Tester is deprecated; use class
|
by: Thomas Heller |
last post by:
I'm trying to integrate some doctest tests with unittest. The tests
must be exposed as one or more subclasses of unittest.TestCase, so I'm
collecting them with a call to doctest.DocTestSuite(), and then add them
to a TestCase class I have created.
The tests seem to run, but they always seem to succeed - I have no idea
why. Any ideas?
Thomas
---snip---
|
by: Michele Simionato |
last post by:
I am getting trouble with nested triple quoted strings in doctest.
For instance
$ cat x.py
"""
>>> dummy = '''
something
here
'''
"""
| |
by: Runsun Pan |
last post by:
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):
|
by: Paddy |
last post by:
Hi,
Anyone know of something that can turn an interactive bash or tcsh
session into a test the
way doctest does?
- Cheers, Paddy.
|
by: Eric Mahurin |
last post by:
Noob here. Just got into python a little over a week ago...
One of the (unique?) things I really like about python is the concept
of doctesting. But, now I want more! Here's what I'd like to see:
* easy debugging. As soon as there is a failure (unexpected exception
or mismatch), drop down into the debugger in a way to isolates the bug
down to the nearest test/example as much as possible.
* integrated with code coverage. I'd like...
|
by: Bzyczek |
last post by:
Hello,
I have problems with running doctests if I use czech national
characters in UTF-8 encoding.
I have Python script, which begin with encoding definition:
# -*- coding: utf-8 -*-
I have this function with doctest:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |