xonsh/tests/test_main.py
Benjamin Pollack 533a7e915f Add support for -i and -l options
Support for the login option is very minimal, but the `XONSH_LOGIN`
variable is set in this case so that scripts may take an appropriate
action.

Fixes #517
2015-11-21 18:26:34 -05:00

29 lines
722 B
Python

# -*- coding: utf-8 -*-
"""Tests the xonsh main function."""
from __future__ import unicode_literals, print_function
import builtins
from unittest.mock import patch
import nose
from nose.tools import assert_true, assert_false
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([])
assert_false(builtins.__xonsh_env__.get('XONSH_LOGIN'))
with patch('xonsh.main.Shell', Shell), mock_xonsh_env({}):
xonsh.main.premain(['-l'])
assert_true(builtins.__xonsh_env__.get('XONSH_LOGIN'))
if __name__ == '__main__':
nose.runmodule()