changeset 5385:e9fb7c539a52

Python 3 preparation: use exec(compile(open().read())) instead of execfile(). Tool-assisted patch.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 22:18:30 +0000
parents c4774b9f483c
children fc97f1f4a7e3
files test/memorydb.py test/test_cgi.py test/test_xmlrpc.py
diffstat 3 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/memorydb.py	Tue Jul 24 22:11:16 2018 +0000
+++ b/test/memorydb.py	Tue Jul 24 22:18:30 2018 +0000
@@ -38,12 +38,12 @@
     vars['FileClass'] = FileClass
     vars['IssueClass'] = IssueClass
     vars['db'] = db
-    execfile(schema, vars)
+    exec(compile(open(schema).read(), schema, 'exec'), vars)
     initial_data = os.path.join(os.path.dirname(__file__),
         '../share/roundup/templates/classic/initial_data.py')
     vars = dict(db=db, admin_email='admin@test.com',
         adminpw=password.Password('sekrit'))
-    execfile(initial_data, vars)
+    exec(compile(open(initial_data).read(), initial_data, 'exec'), vars)
 
     # load standard detectors
     thisdir = os.path.dirname(__file__)
@@ -52,11 +52,13 @@
     for fn in os.listdir(dirname):
         if not fn.endswith('.py'): continue
         vars = {}
-        execfile(os.path.join(dirname, fn), vars)
+        exec(compile(open(os.path.join(dirname, fn)).read(),
+                     os.path.join(dirname, fn), 'exec'), vars)
         vars['init'](db)
 
     vars = {}
-    execfile(os.path.join(thisdir, "tx_Source_detector.py"), vars)
+    exec(compile(open(os.path.join(thisdir, "tx_Source_detector.py")).read(),
+                 os.path.join(thisdir, "tx_Source_detector.py"), 'exec'), vars)
     vars['init'](db)
 
     '''
--- a/test/test_cgi.py	Tue Jul 24 22:11:16 2018 +0000
+++ b/test/test_cgi.py	Tue Jul 24 22:18:30 2018 +0000
@@ -77,7 +77,10 @@
 
         vars = {}
         thisdir = os.path.dirname(__file__)
-        execfile(os.path.join(thisdir, "tx_Source_detector.py"), vars)
+        exec(compile(open(os.path.join(thisdir,
+                                       "tx_Source_detector.py")).read(),
+                     os.path.join(thisdir, "tx_Source_detector.py"), 'exec'),
+             vars)
         vars['init'](self.db)
 
         test = self.instance.backend.Class(self.db, "test",
--- a/test/test_xmlrpc.py	Tue Jul 24 22:11:16 2018 +0000
+++ b/test/test_xmlrpc.py	Tue Jul 24 22:18:30 2018 +0000
@@ -52,7 +52,10 @@
 
         thisdir = os.path.dirname(__file__)
         vars = {}
-        execfile(os.path.join(thisdir, "tx_Source_detector.py"), vars)
+        exec(compile(open(os.path.join(thisdir,
+                                       "tx_Source_detector.py")).read(),
+                     os.path.join(thisdir, "tx_Source_detector.py"), 'exec'),
+             vars)
         vars['init'](self.db)
 
         self.server = RoundupInstance(self.db, self.instance.actions, None)

Roundup Issue Tracker: http://roundup-tracker.org/