From a9f1f26a39d782d3ffc7a28ac18697eafe8c5601 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 12 Mar 2011 20:12:19 +0100 Subject: [PATCH] don't import stuff at genscript import time but rather when it is used --- CHANGELOG | 3 +++ _pytest/genscript.py | 10 +++------- pytest.py | 2 +- setup.py | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2c4551c4..4454409f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.0.2 and 2.0.3.dev ---------------------------------------------- +- don't require zlib (and other libs) for genscript plugin without + --genscript actually being used. + - speed up skips (by not doing a full traceback represenation internally) diff --git a/_pytest/genscript.py b/_pytest/genscript.py index 8cb9c2f3a..9eddfcfe0 100755 --- a/_pytest/genscript.py +++ b/_pytest/genscript.py @@ -1,8 +1,5 @@ """ generate a single-file self-contained version of py.test """ import py -import pickle -import zlib -import base64 def find_toplevel(name): for syspath in py.std.sys.path: @@ -31,9 +28,9 @@ def pkg_to_mapping(name): return name2src def compress_mapping(mapping): - data = pickle.dumps(mapping, 2) - data = zlib.compress(data, 9) - data = base64.encodestring(data) + data = py.std.pickle.dumps(mapping, 2) + data = py.std.zlib.compress(data, 9) + data = py.std.base64.encodestring(data) data = data.decode('ascii') return data @@ -44,7 +41,6 @@ def compress_packages(names): mapping.update(pkg_to_mapping(name)) return compress_mapping(mapping) - def generate_script(entry, packages): data = compress_packages(packages) tmpl = py.path.local(__file__).dirpath().join('standalonetemplate.py') diff --git a/pytest.py b/pytest.py index a7b9cce02..37dd2e0b9 100644 --- a/pytest.py +++ b/pytest.py @@ -1,7 +1,7 @@ """ unit and functional testing with Python. """ -__version__ = '2.0.3.dev0' +__version__ = '2.0.3.dev1' __all__ = ['main'] from _pytest.core import main, UsageError, _preloadplugins diff --git a/setup.py b/setup.py index dcf94b75b..562f23c9c 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.3.dev0', + version='2.0.3.dev1', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -67,4 +67,4 @@ def make_entry_points(): return {'console_scripts': l} if __name__ == '__main__': - main() + main() \ No newline at end of file