Skip to content

Commit

Permalink
Merge branch 'docs' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
horkko committed Apr 12, 2016
2 parents 03de3ab + 5b111fd commit 0ac584b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions biomajmanager/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities class for BioMAJ Manager"""
from __future__ import print_function
import os
import sys
from time import time
Expand Down Expand Up @@ -34,7 +35,7 @@ def elapsed_time():
etime = Utils.timer_stop - Utils.timer_start
Utils.reset_timer()
return etime
Utils.error("Missing timer value (start/stop")
Utils.error("Missing timer value (start/stop)")

@staticmethod
def error(msg):
Expand Down Expand Up @@ -153,8 +154,8 @@ def _print(msg, to=sys.stdout):
"""
if not msg:
return
msg.strip()
to.write(str(msg) + "\n")
msg = str(msg).rstrip("\n")
print(msg, file=to)
return

@staticmethod
Expand Down
11 changes: 8 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@

import sys
import os
import mock
import sphinx_rtd_theme
from mock import Mock as MagicMock


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

MOCK_MODULES = ['pycurl', 'pymongo', 'elasticsearch', 'drmaa']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
9 changes: 7 additions & 2 deletions tests/biomaj-manager_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,14 @@ def test_UtilsSayReturnsNone(self):
def test_UtilsSayReturnsOK(self):
"""Check the method returns correct message"""
expected = "OK\n"
from StringIO import StringIO
msg = "OK"
# Python3 support
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
out = StringIO()
Utils._print("OK", to=out)
Utils._print(msg, to=out)
returned = out.getvalue()
self.assertEqual(expected, returned)

Expand Down

0 comments on commit 0ac584b

Please sign in to comment.