From 323f0c4e2275e2215fe18d0da2ae5cb90a3f48cb Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 28 Aug 2014 23:58:22 +0400 Subject: [PATCH] Use __import__ checks for skipping bzr/mercurial Closes #1015 --- tests/test_lib.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/test_lib.py b/tests/test_lib.py index 07e356a0..4b078ca5 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -1,23 +1,39 @@ # vim:fileencoding=utf-8:noet from __future__ import division +import threading +import os +import re + +from time import sleep +from subprocess import call, PIPE + from powerline.lib import mergedicts, add_divider_highlight_group, REMOVE_THIS_KEY from powerline.lib.humanize_bytes import humanize_bytes from powerline.lib.vcs import guess, get_fallback_create_watcher from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment from powerline.lib.monotonic import monotonic from powerline.lib.vcs.git import git_directory -import threading -import os -import sys -import re -import platform -from time import sleep -from subprocess import call, PIPE + from tests.lib import Pl from tests import TestCase +try: + __import__('bzrlib') +except ImportError: + use_bzr = False +else: + use_bzr = True + +try: + __import__('mercurial') +except ImportError: + use_mercurial = False +else: + use_mercurial = True + + def thread_number(): return len(threading.enumerate()) @@ -375,10 +391,6 @@ class TestLib(TestCase): self.assertEqual(humanize_bytes(1000000000, si_prefix=False), '953.7 MiB') -use_mercurial = use_bzr = (sys.version_info < (3, 0) - and platform.python_implementation() == 'CPython') - - class TestVCS(TestCase): def do_branch_rename_test(self, repo, q): st = monotonic()