Issue 47 in pymox: StubOutClassWithMocks does not work with abstract base classes (ABC)

83 views
Skip to first unread message

codesite...@google.com

unread,
Apr 12, 2012, 7:53:17 PM4/12/12
to mox-d...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 47 by openvcd...@gmail.com: StubOutClassWithMocks does not work
with abstract base classes (ABC)
http://code.google.com/p/pymox/issues/detail?id=47

What steps will reproduce the problem?
Create a file foo.py containing the following class definitions:
import abc

class Foo(object):
__metaclass__ = abc.ABCMeta

class Bar(Foo):
pass

Now execute the following:
import foo
import mox
mox.Mox().StubOutClassWithMocks(foo, 'Foo')

What is the expected output?
StubOutClassWithMocks() should not produce any errors.

What do you see instead?
Raises "TypeError: Given attr is not a Class. Use StubOutWithMock."

Reason: type(foo.Foo) is <class 'abc.ABCMeta'>, which doesn't fall into any
of the categories in _USE_MOCK_FACTORY.


codesite...@google.com

unread,
Aug 15, 2012, 7:26:58 PM8/15/12
to mox-d...@googlegroups.com

Comment #1 on issue 47 by g...@google.com: StubOutClassWithMocks does not
work with abstract base classes (ABC)
http://code.google.com/p/pymox/issues/detail?id=47

I'm attaching a diff against trunk to add support for this. Please apply
and pull in to our internal version. Thanks! :)

We need this for Python 2.7 support as things being mocked in some code
such as gzip.GZipFile inherit from a <class 'abc.ABCMeta'> base class.

Attachments:
mox-issue47-abc-gps01.diff 2.9 KB

codesite...@google.com

unread,
Nov 16, 2012, 12:41:25 PM11/16/12
to mox-d...@googlegroups.com

Comment #2 on issue 47 by g...@google.com: StubOutClassWithMocks does not
work with abstract base classes (ABC)
http://code.google.com/p/pymox/issues/detail?id=47

We really need this.

Steve Middlekauff

unread,
Nov 16, 2012, 12:44:59 PM11/16/12
to mox-d...@googlegroups.com
I'll handle this when I get into the office.  Sorry for the delay.  :-(



--
You received this message because you are subscribed to the Google Groups "mox-discuss" group.
To post to this group, send email to mox-d...@googlegroups.com.
To unsubscribe from this group, send email to mox-discuss+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mox-discuss?hl=en.




--
Steve Middlekauff
steve.mi...@gmail.com

codesite...@google.com

unread,
Nov 16, 2012, 2:19:06 PM11/16/12
to mox-d...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 47 by steve.mi...@gmail.com: StubOutClassWithMocks does
not work with abstract base classes (ABC)
http://code.google.com/p/pymox/issues/detail?id=47

Submitted as Revision 75.

Reply all
Reply to author
Forward
0 new messages