derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

A mock with the same name in a different compilation unit can result in runtime crash #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a mock
2. Create another mock with the same name in a different compilation unit
3. At runtime, using the mock can result in runtime crash

What is the expected output? What do you see instead?
Compile time error if two mocks have the same name, or at the very least a user 
readable runtime assert.

What version of the product are you using? On what operating system?
1.5.0, Win64

Please provide any additional information below.
Only crashed in debug, not release in test code

Original issue reported on code.google.com by kie...@koding.co.uk on 14 Jul 2011 at 10:48

GoogleCodeExporter commented 9 years ago
Can you be more specific (example code that shows the problem). I can create 
and use two mocks with the same name without problem:
{{{

>>> from mock import Mock
>>> m = Mock(name='foo')
>>> m2 = Mock(name='foo')
>>> m()
<mock.Mock object at 0x50ae70>
>>> m2()
<mock.Mock object at 0x50a890>

}}}

I'm afraid I don't know what you mean by "in a different compilation unit". Do 
you mean in different python modules? I can do that without problem as well:

{{{
$ echo "from mock import Mock
> m = Mock(name='foo')" > one.py
$ cp one.py two.py
$ python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from one import m as m1
>>> from two import m as m2
>>> m1()
<mock.Mock object at 0x50aa70>
>>> m2()
<mock.Mock object at 0x50a890>
}}}

Original comment by fuzzyman on 14 Jul 2011 at 10:54

GoogleCodeExporter commented 9 years ago
This is embarrassing. I thought this was the issues list for Google mock to be 
used as part of the Google test suite.

Thanks anyway for the quick reply.

Original comment by kie...@koding.co.uk on 14 Jul 2011 at 12:29

GoogleCodeExporter commented 9 years ago
Hah. You'll have many fewer problems if you switch to "mock". ;-)

Original comment by fuzzyman on 14 Jul 2011 at 12:31