From 20032ecaa561247b67f0de3af8e0b84e7ed4d33a Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Wed, 31 Aug 2016 10:49:22 +0200 Subject: [PATCH 1/5] Skip dirstack_unc tests if drive letters are already used by windows --- tests/test_dirstack_unc.py | 7 +++++++ 1 file changed, 7 insertions(+) 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): From 87ec9e4c07424b46def6984f9a0aac6599d77881 Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Thu, 1 Sep 2016 11:54:45 +0200 Subject: [PATCH 2/5] Disables win_unicode_console in tests if it is installed. The packages collides with the pytest output capture and causes some tests to error. --- tests/conftest.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index d4a5846c8..bfaf31eb4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,10 +9,12 @@ 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 + + @pytest.fixture def xonsh_execer(monkeypatch): """Initiate the Execer with a mocked nop `load_builtins`""" @@ -65,3 +67,17 @@ def xonsh_builtins(): del builtins.compilex del builtins.aliases del builtins.events + +if ON_WINDOWS: + try: + import win_unicode_console + HAVE_WIN_UNICODE_CONSOLE = True + except ImportError: + HAVE_WIN_UNICODE_CONSOLE = False + + if HAVE_WIN_UNICODE_CONSOLE: + @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) From b162552d6dd745caafc6edea1f9bc8415d2220e6 Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Thu, 1 Sep 2016 11:57:18 +0200 Subject: [PATCH 3/5] Add news entry --- news/win_test_fixes.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 news/win_test_fixes.rst 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 From f8c8c519a339fdf1c5d10b602a8850cee04a6875 Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Thu, 1 Sep 2016 12:03:55 +0200 Subject: [PATCH 4/5] Simplify code a bit --- tests/conftest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index bfaf31eb4..f0a727c2a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -71,11 +71,9 @@ def xonsh_builtins(): if ON_WINDOWS: try: import win_unicode_console - HAVE_WIN_UNICODE_CONSOLE = True except ImportError: - HAVE_WIN_UNICODE_CONSOLE = False - - if HAVE_WIN_UNICODE_CONSOLE: + pass + else: @pytest.fixture(autouse=True) def disable_win_unicode_console(monkeypatch): """ Disable win_unicode_console if it is present since it collides with From f1dab1a853d6582ab4f6bee8116bb59a4bd3bd6a Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Thu, 1 Sep 2016 12:47:35 +0200 Subject: [PATCH 5/5] pep8 --- tests/conftest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f0a727c2a..5df6d08de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,8 +13,6 @@ from xonsh.platform import ON_WINDOWS from tools import DummyShell, sp - - @pytest.fixture def xonsh_execer(monkeypatch): """Initiate the Execer with a mocked nop `load_builtins`""" @@ -68,6 +66,7 @@ def xonsh_builtins(): del builtins.aliases del builtins.events + if ON_WINDOWS: try: import win_unicode_console