Skip to content

Commit

Permalink
mock_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Jan 13, 2015
1 parent 5dcdb59 commit 36c3e78
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 1 addition & 9 deletions py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@

if os.environ.get('READTHEDOCS', None) == 'True':
# hack for building docs on rtfd

import sys
from unittest.mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()

from .mock_module import Mock
MOCK_MODULES = ['numpy', 'pandas', 'larch._core', 'larch.apsw']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

Expand Down
7 changes: 6 additions & 1 deletion py/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

from . import apsw
try:
from . import apsw
except ImportError:
from .mock_module import Mock
apsw = Mock()

from . import utilities
from .core import SQLiteDB, Facet, FacetError, LarchError, QuerySetSimpleCO
from .exceptions import NoResultsError, TooManyResultsError
Expand Down
10 changes: 10 additions & 0 deletions py/mock_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


import sys
from unittest.mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()

0 comments on commit 36c3e78

Please sign in to comment.