예제 #1
0
def test_environment():
    '''
    Test information about the environment we are running under.
    '''
    if hasattr(builtins, '__IPYTHON__'):
        testing_under_ipython = True
        del builtins.__IPYTHON__
    else:
        testing_under_ipython = False

    assert not running_from_ipython()
    builtins.__IPYTHON__ = True
    assert running_from_ipython()

    if not testing_under_ipython:
        del builtins.__IPYTHON__
예제 #2
0
def test_environment():
    '''
    Test information about the environment we are running under.
    '''
    import __builtin__
    
    if hasattr(__builtin__, '__IPYTHON__'):
        testing_under_ipython = True
        del __builtin__.__IPYTHON__
    else:
        testing_under_ipython = False
    
    assert not running_from_ipython()
    __builtin__.__IPYTHON__ = True
    assert running_from_ipython()
    
    if not testing_under_ipython:
        del __builtin__.__IPYTHON__
예제 #3
0
def test_environment():
    '''
    Test information about the environment we are running under.
    '''
    try:
        # Python 2
        import __builtin__ as builtins
    except ImportError:
        # Python 3
        import builtins

    if hasattr(builtins, '__IPYTHON__'):
        testing_under_ipython = True
        del builtins.__IPYTHON__
    else:
        testing_under_ipython = False

    assert not running_from_ipython()
    builtins.__IPYTHON__ = True
    assert running_from_ipython()

    if not testing_under_ipython:
        del builtins.__IPYTHON__
예제 #4
0
def test_environment():
    '''
    Test information about the environment we are running under.
    '''
    try:
        # Python 2
        import __builtin__ as builtins
    except ImportError:
        # Python 3
        import builtins
    
    if hasattr(builtins, '__IPYTHON__'):
        testing_under_ipython = True
        del builtins.__IPYTHON__
    else:
        testing_under_ipython = False
    
    assert not running_from_ipython()
    builtins.__IPYTHON__ = True
    assert running_from_ipython()
    
    if not testing_under_ipython:
        del builtins.__IPYTHON__