Use __import__ checks for skipping bzr/mercurial

Closes #1015
This commit is contained in:
ZyX 2014-08-28 23:58:22 +04:00
parent 305fd7917b
commit 323f0c4e22

View File

@ -1,23 +1,39 @@
# vim:fileencoding=utf-8:noet # vim:fileencoding=utf-8:noet
from __future__ import division 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 import mergedicts, add_divider_highlight_group, REMOVE_THIS_KEY
from powerline.lib.humanize_bytes import humanize_bytes from powerline.lib.humanize_bytes import humanize_bytes
from powerline.lib.vcs import guess, get_fallback_create_watcher from powerline.lib.vcs import guess, get_fallback_create_watcher
from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment
from powerline.lib.monotonic import monotonic from powerline.lib.monotonic import monotonic
from powerline.lib.vcs.git import git_directory 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.lib import Pl
from tests import TestCase 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(): def thread_number():
return len(threading.enumerate()) return len(threading.enumerate())
@ -375,10 +391,6 @@ class TestLib(TestCase):
self.assertEqual(humanize_bytes(1000000000, si_prefix=False), '953.7 MiB') 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): class TestVCS(TestCase):
def do_branch_rename_test(self, repo, q): def do_branch_rename_test(self, repo, q):
st = monotonic() st = monotonic()