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

Change subject: fix verbosity while testing
......................................................................


fix verbosity while testing

Call logging.basicConfig otherwise log level is silent during testing
which is inconvenient. Also rename TestWikidata into WikidataHelper so
that pytest does not mistake it for a class that contains tests.

Change-Id: I031d8e14f7706323770057da6bbc2aa8fc02bd26
Signed-off-by: Loic Dachary <l...@dachary.org>
---
M FLOSSbot/bot.py
M tests/test_bot.py
M tests/test_repository.py
M tests/wikidata.py
4 files changed, 14 insertions(+), 11 deletions(-)

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



diff --git a/FLOSSbot/bot.py b/FLOSSbot/bot.py
index a2509e3..a0690e7 100644
--- a/FLOSSbot/bot.py
+++ b/FLOSSbot/bot.py
@@ -117,7 +117,7 @@
                 return candidate
         candidates = []
         for p in site.search_entities(name, 'en', **kwargs):
-            # log.debug("looking for entity " + name + ", found " + str(p))
+            log.debug("looking for entity " + name + ", found " + str(p))
             if p.get('label') == name:
                 if kwargs['type'] == 'property':
                     candidates.append(p)
diff --git a/tests/test_bot.py b/tests/test_bot.py
index 24fe02f..f600df3 100644
--- a/tests/test_bot.py
+++ b/tests/test_bot.py
@@ -16,21 +16,19 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 import argparse
-import logging
 from datetime import date
 
 import pytest
 import pywikibot
 
 from FLOSSbot.bot import Bot
-from tests.wikidata import TestWikidata
+from tests.wikidata import WikidataHelper
 
 
 class TestBot(object):
 
     def setup_class(cls):
-        logging.getLogger('FLOSSbot').setLevel(logging.DEBUG)
-        TestWikidata().login()
+        WikidataHelper().login()
 
     def test_lookup_item(self):
         bot = Bot(argparse.Namespace(
@@ -95,7 +93,7 @@
             dry_run=False,
             verification_delay=30,
         ))
-        item = bot.__getattribute__('Q_' + TestWikidata.random_name())
+        item = bot.__getattribute__('Q_' + WikidataHelper.random_name())
         claim = pywikibot.Claim(bot.site,
                                 bot.P_source_code_repository,
                                 0)
@@ -112,7 +110,7 @@
             test=True,
             user='FLOSSbotCI',
         ))
-        name = TestWikidata.random_name()
+        name = WikidataHelper.random_name()
         entity = {
             "labels": {
                 "en": {
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 47a05e9..be5ca83 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -20,13 +20,13 @@
 import pywikibot
 
 from FLOSSbot.repository import Repository
-from tests.wikidata import TestWikidata
+from tests.wikidata import WikidataHelper
 
 
 class TestRepository(object):
 
     def setup_class(self):
-        TestWikidata().login()
+        WikidataHelper().login()
 
     def setup(self):
         self.r = Repository.factory([
@@ -99,7 +99,7 @@
             dry_run=False,
             verification_delay=30,
         ))
-        item = r.__getattribute__('Q_' + TestWikidata.random_name())
+        item = r.__getattribute__('Q_' + WikidataHelper.random_name())
         claim = pywikibot.Claim(r.site,
                                 r.P_source_code_repository,
                                 0)
diff --git a/tests/wikidata.py b/tests/wikidata.py
index a74a898..708748f 100644
--- a/tests/wikidata.py
+++ b/tests/wikidata.py
@@ -14,6 +14,7 @@
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+import logging
 import random
 import string
 
@@ -21,7 +22,11 @@
 from pywikibot.data import api
 
 
-class TestWikidata(object):
+class WikidataHelper(object):
+
+    def __init__(self):
+        logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s')
+        logging.getLogger('FLOSSbot').setLevel(logging.DEBUG)
 
     def login(self):
         site = pywikibot.Site("test", "wikidata", "FLOSSbotCI")

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I031d8e14f7706323770057da6bbc2aa8fc02bd26
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/bots/FLOSSbot
Gerrit-Branch: master
Gerrit-Owner: Dachary <l...@dachary.org>
Gerrit-Reviewer: Dachary <l...@dachary.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to