[QUOTE=TheMaxx;26890]you’d have to find everything in a default argument and mock that, i’m still not sure why you Mock class isn’t working as expected. The modules just need to be importable, but not actually work.
hmmm, your class works in python 3
edit: try this
class Mock(MagicMock):
__all__ = ['QApplication','pyqtSignal','pyqtSlot','QObject','QAbstractItemModel','QModelIndex','QTabWidget',
'QWebPage','QTableView','QWebView','QAbstractTableModel','Qt','QWidget','QPushButton','QDoubleSpinBox',
'QListWidget','QDialog','QSize','QTableWidget','QMainWindow','QTreeWidget',
'QAbstractItemDelegate','QColor','QGraphicsItemGroup','QGraphicsItem','QGraphicsPathItem',
'QGraphicsTextItem','QGraphicsRectItem','QGraphicsScene','QGraphicsView',]
def __init__(self, *args, **kwargs):
super(Mock, self).__init__()
@classmethod
def __getattr__(cls, name):
if name in ('__file__', '__path__'):
return os.devnull
else:
return Mock()
@classmethod
def __setattr__(*args, **kwargs):
pass
def __setitem__(self, *args, **kwargs):
return
def __getitem__(self, *args, **kwargs):
return Mock()
[/QUOTE]
I actually have this right now:
class Mock(MagicMock):
__all__ = ['QApplication','pyqtSignal','pyqtSlot','QObject','QAbstractItemModel','QModelIndex','QTabWidget',
'QWebPage','QTableView','QWebView','QAbstractTableModel','Qt','QWidget','QPushButton','QDoubleSpinBox',
'QListWidget','QDialog','QSize','QTableWidget','QMainWindow','QTreeWidget',
'QAbstractItemDelegate','QColor','QGraphicsItemGroup','QGraphicsItem','QGraphicsPathItem',
'QGraphicsTextItem','QGraphicsRectItem','QGraphicsScene','QGraphicsView', 'MaxPlus']
def __init__(self, *args, **kwargs):
super(Mock, self).__init__()
@classmethod
def __getattr__(cls, name):
if name in ('__file__', '__path__'):
return os.devnull
else:
return Mock()
@classmethod
def __setattr__(*args, **kwargs):
pass
def __setitem__(self, *args, **kwargs):
return
def __getitem__(self, *args, **kwargs):
return Mock()
@classmethod
def GetMainMenu(cls):
return Mock()
@classmethod
def GetSceneDir(cls):
return Mock()
@classmethod
def GetRenderOutputDir(cls):
return Mock()
@classmethod
def Get3DSMAXVersion(cls):
return 1114123264
@classmethod
def EvalMAXScript(cls, *args):
return Mock()
@classmethod
def Get(*args):
return Mock()
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas', 'MaxPlus']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
autodoc_mock_imports = [
'MaxPlus',
'_MaxPlus',
]
Problem is, now all my assert checks are generating the warnings during compile time.
As an aside, is there any way I can redirect warning output to a log file as well? I’m just running
make html > buildlog.txt
and in my conf.py I have a quick class to redirect sys.stdout:
class Logger(object):
def __init__(self):
self.terminal = sys.stdout
self.log = open("buildLog.txt", "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
sys.stdout = Logger()
Which works for print statements and the like, but not warnings…those still only show up in the console.
Thanks for the help so far man! Appreciate it!