Support #600
python vs c++ tests
100%
Description
Email exchange
Anastasia:
Dear Chris,
First, I had some Python unit testing question. As I told you last week, I
am writing the unit tests for Digitization and Space points (in Python
now,
as you suggested). I am trying to write a test function in the python file
for a function in Digitization (C++) that takes in 2 arguments that are
Json::Value (like Json objects). So when I am creating test Json objects
in
the python file and try to 'test' them (i.e. call the function in
Digitization), python complains (says something like Error Type, second
argument of Json Value). Here are the 3 lines of code I am talking about:testJson1 = '{"channel_id":[{"tracker_number":0,
"station_number":0,
"channel_number": 0}]}'
testJson2 = '{"channel_id":[{"tracker_number":0,
"station_number":0,
"channel_number": 0}]}'
test1 = json.loads(testJson1)
test2 = json.loads(testJson2)
self.assertTrue(self.mapper.Check_param(test1, test2))I was just wondering whether you think there might be a problem with
passing
a Json object created in python to a function in C++...
Rogers:
Can you attach:
The map code
The test code
Full copy of the outputHow are you finding the process of testing C++ code in python? Is it
painful?
Anastasia
Attached is the all the code and the output of the test (the error I
get). Once again, thanks a lot for the help!
I wouldn't say that testing C++ code in python is too painful.. One of
my biggest problems is that I am a lot less familiar with python than
with C++. Also, I feel like there are certain things that C++ uses
that Python doesn't really have.. For example, the other day I was
trying to find a way to pass a pointer in a Python function, and I
couldn't really find a way to do that either..
Best regards,
Anastasia
Files
Updated by Rogers, Chris about 12 years ago
Yeah, I don't think SWIG is clever enough to convert from python dict to json::Value. I think the only way is to make a small wrapper function that takes a std::string and converts to Json::Value to do the test. A bit of a pain...
Updated by Rogers, Chris about 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100