Having trouble with gmock_gen.py

1,184 views
Skip to first unread message

Dwight Barker

unread,
Jul 28, 2010, 4:48:20 PM7/28/10
to Google C++ Mocking Framework
I'm attempting to generate some mocks from a header, actually from the
class discussed in the docs:

class Turtle
{
virtual ~Turtle() {}
virtual void PenUp() = 0;
virtual void PenDown() = 0;
virtual void Forward(int distance) = 0;
virtual void Turn(int degrees) = 0;
virtual void GoTo(int x, int y) = 0;
virtual int GetX() const = 0;
virtual int GetY() const = 0;
};

I'm not familiar with Python, but not sure what's happening.

I'm using this on the command line:

gmock_gen.py turtle.h

From that, I get the following:

Traceback (most recent call last):
File "C:\PROJECTS\gmock\scripts\generator\gmock_gen.py", line 31, in
<module> gmock_class.main()
File "C:\PROJECTS\gmock\scripts\generator\cpp\gmock_class.py", line
173, in main
lines = _GenerateMocks(filename, source, entire_ast,
desired_class_names)
File "C:\PROJECTS\gmock\scripts\generator\cpp\gmock_class.py", line
92, in _GenerateMocks
processed_class_names = sets.Set()
NameError: global name 'sets' is not defined

I really don't have much of a clue. Do I need to definte "sets"
somehow?

Thanks for any direction you can provide.

Zhanyong Wan (λx.x x)

unread,
Jul 28, 2010, 4:53:38 PM7/28/10
to Dwight Barker, Google C++ Mocking Framework
sets is a standard Python module. Do you have an up-to-date and
working Python installation? What's its version? Thanks,

--
Zhanyong

Dwight Barker

unread,
Jul 28, 2010, 5:04:49 PM7/28/10
to Google C++ Mocking Framework
Yes, just downloaded it the other day. It says:

"Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32
bit (Intel)] on win32"

Zhanyong Wan (λx.x x)

unread,
Jul 28, 2010, 5:10:58 PM7/28/10
to Dwight Barker, Google C++ Mocking Framework
Python 3.x is incompatible with Python 2.x
(http://wiki.python.org/moin/Python2orPython3), which gmock_gen.py
uses. Can you install Python 2.x instead? Ideally we should fix the
script to work with either version of Python, but we are short of time
now. Thanks,

--
Zhanyong

Zhanyong Wan (λx.x x)

unread,
Jul 28, 2010, 6:02:22 PM7/28/10
to Dwight Barker, Google C++ Mocking Framework
(adding back the mailing list)

On Wed, Jul 28, 2010 at 2:56 PM, Dwight Barker <barker...@gmail.com> wrote:
> Uninstalled 3.x, installed Python 2.7.  Rebooted and tried again. Error is essentially the same:


>
> Traceback (most recent call last):

>  File "gmock_gen.py", line 31, in <module>     gmock_class.main()


>  File "C:\PROJECTS\gmock\scripts\generator\cpp\gmock_class.py", line 173, in main
>    lines = _GenerateMocks(filename, source, entire_ast, desired_class_names)
>  File "C:\PROJECTS\gmock\scripts\generator\cpp\gmock_class.py", line 92, in _GenerateMocks
>    processed_class_names = sets.Set()
> NameError: global name 'sets' is not defined
>

> Maybe my system just has a weird config.

sets should be in Python 2.7, even though it's deprecated:
http://docs.python.org/library/sets.html

So I'm not sure what's wrong.
>
> - Dwight

--
Zhanyong

Reply all
Reply to author
Forward
0 new messages