zopefoundation / Products.PythonScripts

Provides support for restricted execution of Python scripts in Zope.
Other
6 stars 10 forks source link

Tests for zope2 -> zope4 migration on python2 #56

Closed perrinjerome closed 2 years ago

perrinjerome commented 2 years ago

Tests for https://github.com/zopefoundation/Products.PythonScripts/issues/55


For reference, the included src/Products/PythonScripts/tests/tscripts/ps_2.13.2.pkl is a pickle created from running this python script within a Zope 2.13.30 buildout, using python 2.7.13 on linux.

[buildout]
extends = https://zopefoundation.github.io/Zope/releases/2.13.30/versions-prod.cfg
show-picked-versions = true
parts = zopectl

[versions]
plone.recipe.zope2instance = < 5
mailinglogger = < 6
zc.buildout =
import pickle
import Products.PythonScripts.PythonScript

ps = Products.PythonScripts.PythonScript.PythonScript('test')
ps.write(
'''\
## Script (Python) "test"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=Products_PythonScripts_version='2.13.2'
##title=
##
return """This is an old script created with
Products.PythonScripts version %s
and Zope version 2.13.30 (on python 2.7)
""" % Products_PythonScripts_version
''')

with open('ps_2.13.2.pkl', 'wb') as f:
  pickle.dump(ps, f, 1)
./bin/instance make_pickle.py
perrinjerome commented 2 years ago

Test are currently failing on py27, they can only pass once we'll have a new Zope 4 release with https://github.com/zopefoundation/Zope/pull/1045

perrinjerome commented 2 years ago

Thanks @dataflake and sorry for the delay before merging.