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

Change subject: pwb_tests: set PYWIKIBOT2_DIR from base_dir
......................................................................


pwb_tests: set PYWIKIBOT2_DIR from base_dir

If the tests are run from setup.py test without PYWIKIBOT2_DIR set,
it will use base_dir='~/.pywikibot'. This is OK for all tests, except
when calling pwb.py -- which will assume base_dir is the checkout dir
instead, and thus ask for information to create a new user-config.py.

This commit makes sure PYWIKIBOT2_DIR is set to base_dir (='~/.pywikibot')
before calling pwb.py, which will make pwb.py check that directory instead.

Change-Id: I0a277425b4f9df5b64c325b7d2712f4ba007a260
Fixes-Change-Id: Ic8522e1f08c359fff4085c172e696e62ca969a70
Fixes-Change-Id: Iaeaaf1b34d3e2bcacf8308d2c3b74bd8f711ec6a
Fixes-Change-Id: If9458fca50f07f08441dbb6e06f78bdbae2065de
---
M tests/pwb_tests.py
1 file changed, 10 insertions(+), 4 deletions(-)

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



diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index 5a97483..506b02f 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -12,17 +12,23 @@
 
 import unittest
 
+import pywikibot
+
 pypath = sys.executable
 basepath = os.path.split(os.path.split(__file__)[0])[0]
 pwbpath  = os.path.join(basepath, 'pwb.py')
 testbasepath = os.path.join(basepath, 'tests', 'pwb')
 
 class TestPwb(unittest.TestCase):
-    @unittest.skip("""Skipping test due to broken Travis run.
+    def setUp(self):
+        self.oldenviron = os.environ.copy()
+        os.environ['PYWIKIBOT2_DIR'] = pywikibot.config.base_dir
 
-Probably the shelling out causes an issue, but we have to investigate this.
-See https://gerrit.wikimedia.org/r/#/c/76486/ and
-    https://gerrit.wikimedia.org/r/#/c/82370/ for details. """)
+    def tearDown(self):
+        del os.environ['PYWIKIBOT2_DIR']
+        if 'PYWIKIBOT2_DIR' in self.oldenviron:
+            os.environ['PYWIKIBOT2_DIR'] = self.oldenviron['PYWIKIBOT2_DIR']
+
     def testScriptEnvironment(self):
         """Make sure the environment is not contaminated, and is the same as
            the environment we get when directly running a script."""

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

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

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

Reply via email to