diff --git a/news/win_test_fixes.rst b/news/win_test_fixes.rst new file mode 100644 index 000000000..9dad37141 --- /dev/null +++ b/news/win_test_fixes.rst @@ -0,0 +1,13 @@ +**Added:** None + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** + +* Fix some test problems when win_unicode_console was installed on windows. + +**Security:** None diff --git a/tests/conftest.py b/tests/conftest.py index d4a5846c8..5df6d08de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ from xonsh.built_ins import ensure_list_of_strs from xonsh.execer import Execer from xonsh.tools import XonshBlockError from xonsh.events import events - +from xonsh.platform import ON_WINDOWS from tools import DummyShell, sp @@ -65,3 +65,16 @@ def xonsh_builtins(): del builtins.compilex del builtins.aliases del builtins.events + + +if ON_WINDOWS: + try: + import win_unicode_console + except ImportError: + pass + else: + @pytest.fixture(autouse=True) + def disable_win_unicode_console(monkeypatch): + """ Disable win_unicode_console if it is present since it collides with + pytests ouptput capture""" + monkeypatch.setattr(win_unicode_console, 'enable', lambda: None) diff --git a/tests/test_dirstack_unc.py b/tests/test_dirstack_unc.py index d87652bc3..bc6cfb999 100644 --- a/tests/test_dirstack_unc.py +++ b/tests/test_dirstack_unc.py @@ -23,6 +23,13 @@ from xonsh.dirstack import _unc_tempDrives HERE = os.path.abspath(os.path.dirname(__file__)) PARENT = os.path.dirname(HERE) +def drive_in_use(letter): + return ON_WINDOWS and os.system('vol {}: 2>nul>nul'.format(letter)) == 0 + +pytestmark = pytest.mark.skipif(any(drive_in_use(l) for l in 'ywzx'), + reason='Drive letters used by tests are ' + 'are already used by Windows.') + @pytest.yield_fixture(scope="module") def shares_setup(tmpdir_factory):