Skip to content

Commit

Permalink
test that __code__ and __defaults__ are set on PythonScripts
Browse files Browse the repository at this point in the history
and on python2, the old func_code and func_defaults
  • Loading branch information
perrinjerome committed May 23, 2022
1 parent 990c32b commit c1e1fba
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Products/PythonScripts/tests/testPythonScript.py
Expand Up @@ -384,6 +384,23 @@ def test_factory(self):
self.assertEqual(container.testing.body(), 'return 1\n')
self.assertEqual(container.testing.params(), '')

def testCodeIntrospection(self):
script = self._newPS('##parameters=a="b"')

self.assertEqual(script.__code__.co_argcount, 1)
self.assertEqual(
script.__code__.co_varnames,
('a',))
if six.PY2:
self.assertEqual(script.func_code.co_argcount, 1)
self.assertEqual(
script.func_code.co_varnames,
('a',))

self.assertEqual(script.__defaults__, ('b',))
if six.PY2:
self.assertEqual(script.func_defaults, ('b',))


class TestPythonScriptErrors(PythonScriptTestBase):

Expand Down

0 comments on commit c1e1fba

Please sign in to comment.