jenkins-bot has submitted this change and it was merged.

Change subject: Export sys.path to pwb scripts
......................................................................


Export sys.path to pwb scripts

setup.py can install packages, which are available within the
unit tests as it adds the packages to sys.path.

script_tests needs to export sys.path into the script environment
so these packages may be imported by the script.

Also move a docstring which was incorrectly placed inside the method
procedure.

Bug: 71864
Change-Id: I6356b4b5d8da7529957befe8157f78457ebb5df1
---
M tests/script_tests.py
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  XZise: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/script_tests.py b/tests/script_tests.py
index f4252e3..af9e37a 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -207,6 +207,8 @@
             return stream.decode(config.console_encoding)
         else:
             return stream
+    env = os.environ.copy()
+    env['PYTHONPATH'] = ":".join(sys.path)
     options = {
         'stdout': subprocess.PIPE,
         'stderr': subprocess.PIPE
@@ -214,7 +216,7 @@
     if data_in is not None:
         options['stdin'] = subprocess.PIPE
 
-    p = subprocess.Popen(command, **options)
+    p = subprocess.Popen(command, env=env, **options)
 
     if data_in is not None:
         if sys.version_info[0] > 2:
@@ -412,8 +414,8 @@
     __metaclass__ = TestScriptMeta
 
     def setUp(self):
-        super(TestScript, self).setUp()
         """Prepare the environment for running the pwb.py script."""
+        super(TestScript, self).setUp()
         self.old_pywikibot_dir = None
         if 'PYWIKIBOT2_DIR' in os.environ:
             self.old_pywikibot_dir = os.environ['PYWIKIBOT2_DIR']

-- 
To view, visit https://gerrit.wikimedia.org/r/171194
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6356b4b5d8da7529957befe8157f78457ebb5df1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to