mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00

I wouldn't normally do something like this but issue #487 brought to my attention the fact that too many of the python modules don't have an encoding comment and of those that do there is a lot of pointless inconsistency in the style of the comment.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Testing xonsh import hooks"""
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
import nose
|
|
from nose.tools import assert_equal
|
|
|
|
from xonsh import imphooks # noqa
|
|
from xonsh import built_ins
|
|
from xonsh.execer import Execer
|
|
from xonsh.built_ins import load_builtins, unload_builtins
|
|
|
|
LOADED_HERE = False
|
|
|
|
def setup():
|
|
global LOADED_HERE
|
|
if built_ins.BUILTINS_LOADED:
|
|
unload_builtins() # make sure we have a clean env from other tests.
|
|
load_builtins(execer=Execer())
|
|
LOADED_HERE = True
|
|
|
|
def teardown():
|
|
if LOADED_HERE:
|
|
unload_builtins()
|
|
|
|
def test_import():
|
|
import sample
|
|
assert_equal('hello mom jawaka\n', sample.x)
|
|
|
|
def test_absolute_import():
|
|
from xpack import sample
|
|
assert_equal('hello mom jawaka\n', sample.x)
|
|
|
|
def test_relative_import():
|
|
from xpack import relimp
|
|
assert_equal('hello mom jawaka\n', relimp.sample.x)
|
|
assert_equal('hello mom jawaka\ndark chest of wonders', relimp.y)
|
|
|
|
def test_sub_import():
|
|
from xpack.sub import sample
|
|
assert_equal('hello mom jawaka\n', sample.x)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
nose.runmodule()
|