Skip to content

Commit

Permalink
Make code more compact and test less variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner committed Oct 16, 2018
1 parent d631d57 commit ce5a761
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Zope2/utilities/tests/test_zconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

test_script = """
import sys
import Testing
import OFS.PropertyManager
def print_info():
# This tests the availability of global variables and imports.
print(sys.argv[1:])
print(Testing.__doc__[:7]) # `Set up`
# 'ExtensionClass'
print(OFS.PropertyManager.PropertyManager.__class__.__name__)
if __name__ == '__main__':
app.foo = '42'
Expand Down Expand Up @@ -82,6 +83,7 @@ def test_runscript(self):
finally:
sys.argv = self.stored_sys_argv
sys.stdout = self.stored_stdout
expected = "42\n['run', '{}', '{}', 'bar', 'baz']\n\nSet up\n".format(
self.zopeconf, script)
expected = (
"42\n['run', '{}', '{}', 'bar', 'baz']\nExtensionClass\n").format(
self.zopeconf, script)
self.assertEqual(expected, got)
4 changes: 1 addition & 3 deletions src/Zope2/utilities/zconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def runscript(zopeconf, script_name, *extra_args):
app.REQUEST['PARENTS'] = [app]
setRequest(app.REQUEST)
newSecurityManager(None, user)
scriptglobals = {}
scriptglobals.update(__name__='__main__')
scriptglobals.update(app=app)
scriptglobals = {'__name__': '__main__', 'app': app}
with open(script_name) as script:
scriptcode = script.read()
exec(compile(scriptcode, script_name, 'exec'), scriptglobals)
Expand Down

0 comments on commit ce5a761

Please sign in to comment.