-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel Riolo
committed
Apr 15, 2015
1 parent
278ad0d
commit 5d09f05
Showing
4 changed files
with
49 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pdb;pdb.set_trace() | ||
""" Just python classes that only work in | ||
python3. In python < 3 you will get a syntax error. | ||
""" | ||
|
||
from martian.testing import FakeModuleMetaclass | ||
|
||
|
||
class FakeModuleObjectMetaclass(type): | ||
""" Base metaclass to replace object in a fake Module. | ||
In python 3 we need to change the class name for | ||
inner classes. So all test will run in python 2 and 3. | ||
Without this class the name of fakemodule will be | ||
shown double in the class name, like this: | ||
<class 'martiantest.fake.basemodule.basemodule.A'> | ||
If this class name is returned, the doctest will fail. | ||
""" | ||
|
||
def __init__(cls, classname, bases, dict_): | ||
normalname = cls.__qualname__.split('.')[-1:][0] | ||
dict_['__qualname__'] = normalname | ||
cls.__qualname__ = dict_['__qualname__'] | ||
return type.__init__(cls, classname, bases, dict_) | ||
|
||
|
||
class FakeModuleObject(object, metaclass = FakeModuleObjectMetaclass): | ||
pass | ||
|
||
|
||
class FakeModule(object, metaclass = FakeModuleMetaclass): | ||
pass |