Is it possible to use python to unit test C++ code? If yes, is there
any example available?
Thank you. 5 11474
On 21 Dec 2005, at 09:33, sy*******@gmail .com wrote: Is it possible to use python to unit test C++ code? If yes, is there any example available?
Thank you.
-- http://mail.python.org/mailman/listinfo/python-list
You could use Python to unittest a Python module written in C++ I
suppose. I guess that would probably work. I suspect that you would
get better/more accurate/reliable results by writing your tests in C+
+ as well though. sy*******@gmail .com wrote: Is it possible to use python to unit test C++ code? If yes, is there any example available?
If I had to use python to test C++ code, I'd use the Boost python
library: http://www.boost.org/libs/python/doc/ to expose my C++
classes, and write the unittests in python after importing the wrapped
C++ code.
Note, you did ask if it was possible. Is it advisable? That's another
question.
All the best,
Keir.
sylcheung> Is it possible to use python to unit test C++ code? If yes,
sylcheung> is there any example available?
Yes, it's quite possible. Some people even do it. ;-) As for examples, take
a look at Python's own test suite. Much of the code it contains actually
tests modules written in C, which is near enough to C++ for our purposes.
For example, consider that the math module is a thin wrapper around bits of
standard C89 math functions. The test_math.py script then exercises that
code.
So, you'll have to wrap your C++ library to make it available in Python
(check out SWIG and/or Boost and/or Python's Extending and Embedding
documentation), then write test cases. For that, look at the unittest and
doctest modules that come with Python as well as the third-party py.test
package.
Skip
samuel> Thanks. When I use python to unit test my c++ code. Do I need
samuel> only the .o file? or I need the .c/.h files of the c++ code? If
samuel> the input is .c/.h files, how can I compile it for unit testing
samuel> purposes?
Your wrapper module will need the header files from your C++ library and it
will by dynamically linked against the library's .so (or .dll).
Skip This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Edward K. Ream |
last post by:
I would like to say a few (actually more than a few) words here about some
recent discoveries I have made concerning the interaction of Leo and Python.
If you don't want to hear an inventor enthuse about his work, please feel
free not to read further :-)
There are at least three, no four, no five, no six, no seven reasons why Leo
and Python work so well together. Most are new (in my mind) with the 4.1
release of Leo. The first several...
|
by: Josh |
last post by:
We have a program written in VB6 (over 100,000 lines of code and 230 UI
screens) that we want to get out of VB and into a better language. The
program is over 10 years old and has already been ported from VB3 to
VB6, a job which took over two years. We would like to port it to
Python, but we need to continue to offer upgrades and fixes to the
current VB6 version. Does anybody know of ways we could go about
rewriting this, one screen at a...
|
by: Pierre Rouleau |
last post by:
Hi all,
I have a consistent test case where os.popen3() hangs in Windows. The
system hangs when retrieving the lines from the child process stdout.
I know there were several reports related to os.popen3() hanging under
Windows in this group before.
I stumbled on a case where a piece of code works in some occasions and
hangs consistently given different data. It performs exactly the same
on 3 different computers running Windows:
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 380 open (-36) / 3658 closed (+65) / 4038 total (+29)
Bugs : 965 open ( -9) / 6555 closed (+35) / 7520 total (+26)
RFE : 272 open ( +4) / 253 closed ( +2) / 525 total ( +6)
New / Reopened Patches
______________________
| |
by: jezonthenet |
last post by:
I started using Python a couple of days ago - here are a few
questions:
* Doesn't the __main__() method automatically execute when I run my
python program?
* Only when I do an import of my test.py file within python and then
run test.__main__() I can see where my bugs are. Is this correct?
(right now this is my only way of running my python program and see
where I have problems)
* Once I've done an import and then I wish to make a...
|
by: Sh4wn |
last post by:
Hi,
first, python is one of my fav languages, and i'll definitely keep
developing with it. But, there's 1 one thing what I -really- miss:
data hiding. I know member vars are private when you prefix them with
2 underscores, but I hate prefixing my vars, I'd rather add a keyword
before it.
Python advertises himself as a full OOP language, but why does it miss
one of the basic principles of OOP? Will it ever be added to python?
|
by: Brendan Miller |
last post by:
What would heavy python unit testers say is the best framework?
I've seen a few mentions that maybe the built in unittest framework
isn't that great. I've heard a couple of good things about py.test and
nose. Are there other options? Is there any kind of concensus about
the best, or at least how they stack up to each other?
Brendan
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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...
|
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: 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
| |