From 82ddafafa5d43a6714279cd44ff2a0ef1a860913 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 1 Nov 2014 13:03:13 +0800 Subject: [PATCH] skip m2crypto tests on pypy --- shadowsocks/crypto/m2.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/shadowsocks/crypto/m2.py b/shadowsocks/crypto/m2.py index 3539711..8022f81 100644 --- a/shadowsocks/crypto/m2.py +++ b/shadowsocks/crypto/m2.py @@ -79,31 +79,36 @@ def run_method(method): util.run_cipher(cipher, decipher) -def test_aes_128_cfb(): +def check_env(): + # skip this test on pypy and Python 3 + try: + import __pypy__ + from nose.plugins.skip import SkipTest + raise SkipTest + except ImportError: + __pypy__ = None if bytes != str: from nose.plugins.skip import SkipTest raise SkipTest + + +def test_aes_128_cfb(): + check_env() run_method(b'aes-128-cfb') def test_aes_256_cfb(): - if bytes != str: - from nose.plugins.skip import SkipTest - raise SkipTest + check_env() run_method(b'aes-256-cfb') def test_bf_cfb(): - if bytes != str: - from nose.plugins.skip import SkipTest - raise SkipTest + check_env() run_method(b'bf-cfb') def test_rc4(): - if bytes != str: - from nose.plugins.skip import SkipTest - raise SkipTest + check_env() run_method(b'rc4')