Skip to content

Commit

Permalink
Fixes for downstream applications that use Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Jan 22, 2019
1 parent da5c847 commit 50e72c1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sciunit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import importlib
import json
import re
import contextlib
from io import TextIOWrapper, StringIO
from datetime import datetime

Expand Down Expand Up @@ -71,6 +72,17 @@ def printd(*args, **kwargs):
return False


if PYTHON_MAJOR_VERSION == 3:
redirect_stdout = contextlib.redirect_stdout
else: # Python 2
@contextlib.contextmanager
def redirect_stdout(target):
original = sys.stdout
sys.stdout = target
yield
sys.stdout = original


def assert_dimensionless(value):
"""
Tests for dimensionlessness of input.
Expand Down

0 comments on commit 50e72c1

Please sign in to comment.