2015-11-21 12:30:43 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""Tests the xonsh main function."""
|
|
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
|
|
|
|
import builtins
|
|
|
|
from unittest.mock import patch
|
|
|
|
import xonsh.main
|
|
|
|
|
|
|
|
from tools import mock_xonsh_env
|
|
|
|
|
|
|
|
|
|
|
|
def test_login_shell():
|
|
|
|
def Shell(*args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
with patch('xonsh.main.Shell', Shell), mock_xonsh_env({}):
|
|
|
|
xonsh.main.premain([])
|
2016-06-22 17:49:54 -04:00
|
|
|
assert (builtins.__xonsh_env__.get('XONSH_LOGIN'))
|
2016-03-20 19:43:37 -04:00
|
|
|
|
|
|
|
with patch('xonsh.main.Shell', Shell), mock_xonsh_env({}):
|
|
|
|
xonsh.main.premain(['-l', '-c', 'echo "hi"'])
|
2016-06-22 17:49:54 -04:00
|
|
|
assert (builtins.__xonsh_env__.get('XONSH_LOGIN'))
|
2015-11-21 12:30:43 -05:00
|
|
|
|
2016-03-20 21:31:14 -04:00
|
|
|
with patch('xonsh.main.Shell', Shell), mock_xonsh_env({}):
|
|
|
|
xonsh.main.premain(['-c', 'echo "hi"'])
|
2016-06-22 17:49:54 -04:00
|
|
|
assert not (builtins.__xonsh_env__.get('XONSH_LOGIN'))
|
2016-03-20 21:31:14 -04:00
|
|
|
|
2015-11-21 12:30:43 -05:00
|
|
|
with patch('xonsh.main.Shell', Shell), mock_xonsh_env({}):
|
|
|
|
xonsh.main.premain(['-l'])
|
2016-06-22 17:49:54 -04:00
|
|
|
assert (builtins.__xonsh_env__.get('XONSH_LOGIN'))
|