jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Only complain in add_text.py when parameters are present
......................................................................
[FIX] Only complain in add_text.py when parameters are present
Change-Id: Ib6118e5fb2896b38a93ed62b024d451ea0d9bfc7
---
M scripts/add_text.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 77e73eb..b3cd488 100644
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -343,14 +343,14 @@
if textfile and not addText:
with codecs.open(textfile, 'r', config.textfile_encoding) as f:
addText = f.read()
- if not addText:
- pywikibot.error("The text to add wasn't given.")
- return
if not generator:
generator = genFactory.getCombinedGenerator()
if not generator:
pywikibot.showHelp()
return
+ if not addText:
+ pywikibot.error("The text to add wasn't given.")
+ return
if talkPage:
generator = pagegenerators.PageWithTalkPageGenerator(generator)
site = pywikibot.Site()
--
To view, visit https://gerrit.wikimedia.org/r/156674
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6118e5fb2896b38a93ed62b024d451ea0d9bfc7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Sensible error message when no text to add was given
......................................................................
[FIX] Sensible error message when no text to add was given
Change-Id: I86c3bd796db9d335e2a860784d7c483ca374c053
---
M scripts/add_text.py
1 file changed, 5 insertions(+), 3 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 00c9837..77e73eb 100644
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -341,9 +341,11 @@
else:
genFactory.handleArg(arg)
if textfile and not addText:
- f = codecs.open(textfile, 'r', config.textfile_encoding)
- addText = f.read()
- f.close()
+ with codecs.open(textfile, 'r', config.textfile_encoding) as f:
+ addText = f.read()
+ if not addText:
+ pywikibot.error("The text to add wasn't given.")
+ return
if not generator:
generator = genFactory.getCombinedGenerator()
if not generator:
--
To view, visit https://gerrit.wikimedia.org/r/156555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I86c3bd796db9d335e2a860784d7c483ca374c053
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Safer siteinfo warning handling
......................................................................
[FIX] Safer siteinfo warning handling
If a warning is returned with the siteinfo but it's not about the
siteinfo it would throw an error.
Change-Id: I0a8ac9ef78fffc40455650ab6c85ee7902a2bce1
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 7ea6f67..a19afa5 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -985,7 +985,7 @@
raise
else:
result = {}
- if 'warnings' in data:
+ if 'warnings' in data and 'siteinfo' in data['warnings']:
invalid_properties = []
for prop in re.match(u"^Unrecognized values? for parameter "
u"'siprop': ([^,]+(?:, [^,]+)*)$",
--
To view, visit https://gerrit.wikimedia.org/r/156461
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0a8ac9ef78fffc40455650ab6c85ee7902a2bce1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix ItemPage editEntity, and test cases
......................................................................
Fix ItemPage editEntity, and test cases
Iba1fdce1cc199cda0b7f83febdf48ce6a11100e0 resulted in data being
normalised even when it was already normalized, making the data
unrecognisable to the Wikibase API.
The normalization routines have been moved from __normalizeLanguages
and __normalizeData to static methods with a single underscore prefix
so they can be easily accessed from unit tests.
Also fix docstrings to be pep257 compliant.
Bug: 69401
Change-Id: Ia2ff456c550670de924099c5993f109c676f9d39
---
M pywikibot/page.py
M tests/wikibase_tests.py
2 files changed, 100 insertions(+), 16 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index fb5bffe..bb33ccf 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2756,14 +2756,16 @@
self.get()
return self.lastrevid
- def __normalizeLanguages(self, data):
+ @staticmethod
+ def _normalizeLanguages(data):
"""
Helper function to replace site objects with their language codes.
- @param data: The dict to check
+ @param data: The dict to normalize.
@type data: dict
- @return: dict
+ @return: the altered dict from parameter data.
+ @rtype: dict
"""
for key in data:
if isinstance(key, pywikibot.site.BaseSite):
@@ -2771,18 +2773,32 @@
del data[key]
return data
- def __normalizeData(self, data):
- for prop in ('labels', 'descriptions', 'aliases'):
- if prop in data:
- data[prop] = self.__normalizeLanguages(data[prop])
- if prop == 'aliases':
- for key, values in data[prop].iteritems():
- for index, value in enumerate(values):
- data[prop][key][index] = {'language': key,
- 'value': value}
- else:
- for key, value in data[prop].iteritems():
- data[prop][key] = {'language': key, 'value': value}
+ @staticmethod
+ def _normalizeData(data):
+ """
+ Helper function to expand data into the Wikibase API structure.
+
+ @param data: The dict to normalize
+ @type data: dict
+
+ @return: the altered dict from parameter data.
+ @rtype: dict
+ """
+ for prop in ('labels', 'descriptions'):
+ if prop not in data:
+ continue
+ data[prop] = WikibasePage._normalizeLanguages(data[prop])
+ for key, value in data[prop].iteritems():
+ if isinstance(value, basestring):
+ data[prop][key] = {'language': key, 'value': value}
+
+ if 'aliases' in data:
+ for key, values in data['aliases'].iteritems():
+ if (isinstance(values, list) and
+ isinstance(values[0], basestring)):
+ data['aliases'][key] = [{'language': key, 'value': value}
+ for value in values]
+
return data
def getdbName(self, site):
@@ -2814,7 +2830,7 @@
else:
baserevid = None
- data = self.__normalizeData(data)
+ data = WikibasePage._normalizeData(data)
updates = self.repo.editEntity(self._defined_by(singular=True), data,
baserevid=baserevid, **kwargs)
@@ -3473,6 +3489,9 @@
def _formatDataValue(self):
"""
Format the target into the proper JSON datavalue that Wikibase wants.
+
+ @return: Wikibase API representation with type and value.
+ @rtype: dict
"""
return {'value': self._formatValue(),
'type': self.value_types.get(self.type, self.type)
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index a9142dd..9772da4 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -13,8 +13,10 @@
import os
import pywikibot
from pywikibot import pagegenerators
+from pywikibot.page import WikibasePage
from pywikibot.data.api import APIError
import json
+import copy
from tests.utils import PywikibotTestCase, unittest
@@ -444,6 +446,69 @@
self.assertEquals(len(wvlinks), 2)
+class TestWriteNormalizeLang(PywikibotTestCase):
+ """Test cases for routines that normalize languages in a dict.
+
+ Exercises WikibasePage._normalizeLanguages with data that is
+ not normalized and data which is already normalized.
+ """
+
+ def setUp(self):
+ super(TestWriteNormalizeLang, self).setUp()
+ self.site = pywikibot.Site('en', 'wikipedia')
+ self.lang_out = {'en': 'foo'}
+
+ def test_normalize_lang(self):
+ lang_in = {self.site: 'foo'}
+
+ response = WikibasePage._normalizeLanguages(lang_in)
+ self.assertEquals(response, self.lang_out)
+
+ def test_normalized_lang(self):
+ response = WikibasePage._normalizeData(
+ copy.deepcopy(self.lang_out))
+ self.assertEquals(response, self.lang_out)
+
+
+class TestWriteNormalizeData(PywikibotTestCase):
+ """Test cases for routines that normalize data for writing to Wikidata.
+
+ Exercises WikibasePage._normalizeData with data that is not normalized
+ and data which is already normalized.
+ """
+
+ def setUp(self):
+ super(TestWriteNormalizeData, self).setUp()
+ self.data_out = {'aliases':
+ {'en':
+ [
+ {'language': 'en',
+ 'value': 'Bah'}
+ ],
+ },
+ 'labels':
+ {'en':
+ {'language': 'en',
+ 'value': 'Foo'},
+ }
+ }
+
+ def test_normalize_data(self):
+ data_in = {'aliases':
+ {'en': ['Bah']},
+ 'labels':
+ {'en': 'Foo'},
+ }
+
+ response = WikibasePage._normalizeData(data_in)
+ self.assertEquals(response, self.data_out)
+
+ def test_normalized_data(self):
+ response = WikibasePage._normalizeData(
+ copy.deepcopy(self.data_out))
+ self.assertEquals(response, self.data_out)
+
+
if __name__ == '__main__':
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/154111
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2ff456c550670de924099c5993f109c676f9d39
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: JAn Dudík <jan.dudik(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use load_tests protocol within test suite
......................................................................
Use load_tests protocol within test suite
Allow the list of tests to be specified for both
Python 2.6 and 2.7 setup.py using a collector method in __init__.py,
and use load_tests so nosetests also uses the same list of tests to
be run by default.
Provide an ordering that tests basic components first, and steps up
to test scripts which exercise larger parts of the package together.
Disable the ui and weblib tests in the module tests collector instead of
within those test files. This will allow the ui test module to be
restructured so that the functionality is visible when not called on the
command line.
Allow individual tests to be disabled to assist with identifying which
tests are causing problems.
Revise script tests so that test functions exist for scripts which
are problematic, but those tests not included in the default list.
Change-Id: Ic0e18457888b428222a9dcbefcec9e1740b573aa
---
M setup.py
M tests/__init__.py
M tests/script_tests.py
M tests/utils.py
M tox.ini
5 files changed, 230 insertions(+), 42 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 4d64d1f..422561e 100644
--- a/setup.py
+++ b/setup.py
@@ -15,7 +15,6 @@
import itertools
test_deps = []
-testcollector = "tests"
dependencies = ['httplib2>=0.6.0']
@@ -40,7 +39,6 @@
sys.modules['unittest'] = unittest2
script_deps['replicate_wiki.py'] = ['argparse']
- testcollector = "tests.utils.collector"
dependencies.append('ordereddict')
if sys.version_info[0] == 3:
@@ -108,7 +106,7 @@
],
url='https://www.mediawiki.org/wiki/Pywikibot',
download_url='https://github.com/wikimedia/pywikibot-core/archive/master.zip#egg=pywikibo…',
- test_suite=testcollector,
+ test_suite="tests.collector",
tests_require=test_deps,
classifiers=[
'License :: OSI Approved :: MIT License',
diff --git a/tests/__init__.py b/tests/__init__.py
index 919064a..96c3f95 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -36,11 +36,137 @@
"Python 2.6")
sys.exit(1)
+if sys.version_info < (2, 7):
+ # Unittest2 is a backport of python 2.7s unittest module to python 2.6
+ import unittest2 as unittest
+else:
+ import unittest
+
import pywikibot.data.api
from pywikibot.data.api import Request as _original_Request
from pywikibot.data.api import CachedRequest
-_cache_dir = os.path.join(os.path.split(__file__)[0], 'apicache')
+_tests_dir = os.path.split(__file__)[0]
+_cache_dir = os.path.join(_tests_dir, 'apicache')
+
+library_test_modules = [
+ 'date',
+ 'ipregex',
+ 'xmlreader',
+ 'textlib',
+ 'http',
+ 'namespace',
+ 'dry_api',
+ 'dry_site',
+ 'api',
+ 'site',
+ 'page',
+ 'file',
+ 'timestripper',
+ 'pagegenerators',
+ 'wikidataquery',
+ 'weblib',
+ 'i18n',
+ 'ui',
+ 'wikibase',
+]
+
+script_test_modules = [
+ 'pwb',
+ 'script',
+ 'archivebot',
+]
+
+disabled_test_modules = [
+ 'ui',
+]
+
+if os.environ.get('TRAVIS', 'false') == 'true':
+ disabled_test_modules.append('weblib')
+
+disabled_tests = {
+ 'textlib': [
+ 'test_interwiki_format', # example; very slow test
+ ]
+}
+
+
+def _unknown_test_modules():
+ """List tests which are to be executed."""
+ dir_list = os.listdir(_tests_dir)
+ all_test_list = [name[0:-9] for name in dir_list # strip '_tests.py'
+ if name.endswith('_tests.py')
+ and not name.startswith('_')] # skip __init__.py and _*
+
+ unknown_test_modules = [name
+ for name in all_test_list
+ if name not in library_test_modules
+ and name not in script_test_modules]
+
+ return unknown_test_modules
+
+
+extra_test_modules = sorted(_unknown_test_modules())
+
+test_modules = library_test_modules + extra_test_modules + script_test_modules
+
+
+def collector(loader=unittest.loader.defaultTestLoader):
+ """Load the default modules.
+
+ This is the entry point is specified in setup.py
+ """
+ # Note: Raising SkipTest during load_tests will
+ # cause the loader to fallback to its own
+ # discover() ordering of unit tests.
+ if disabled_test_modules:
+ print('Disabled test modules (to run: python -m unittest ...):\n %s'
+ % ', '.join(disabled_test_modules))
+
+ if extra_test_modules:
+ print('Extra test modules (run after library, before scripts):\n %s'
+ % ', '.join(extra_test_modules))
+
+ if disabled_tests:
+ print('Skipping tests (to run: python -m unittest ...):\n %r'
+ % disabled_tests)
+
+ modules = [module
+ for module in library_test_modules +
+ extra_test_modules +
+ script_test_modules
+ if module not in disabled_test_modules]
+
+ test_list = []
+
+ for module in modules:
+ module_class_name = 'tests.' + module + '_tests'
+ if module in disabled_tests:
+ discovered = loader.loadTestsFromName(module_class_name)
+ enabled_tests = []
+ for cls in discovered:
+ for test_func in cls:
+ if test_func._testMethodName not in disabled_tests[module]:
+ enabled_tests.append(
+ module_class_name + '.' +
+ test_func.__class__.__name__ + '.' +
+ test_func._testMethodName)
+
+ test_list.extend(enabled_tests)
+ else:
+ test_list.append(module_class_name)
+
+ tests = loader.loadTestsFromNames(test_list)
+ suite = unittest.TestSuite()
+ suite.addTests(tests)
+ return suite
+
+
+def load_tests(loader=unittest.loader.defaultTestLoader,
+ tests=None, pattern=None):
+ """Load the default modules."""
+ return collector(loader)
+
CachedRequest._get_cache_dir = staticmethod(
lambda *args: CachedRequest._make_dir(_cache_dir))
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 27a2ce3..32073de 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -22,15 +22,15 @@
script_deps = {
- 'script_wui.py': ['crontab', 'lua'],
+ 'script_wui': ['crontab', 'lua'],
# Note: package 'lunatic-python' provides module 'lua'
- 'flickrripper.py': ['ImageTk', 'flickrapi'],
+ 'flickrripper': ['ImageTk', 'flickrapi'],
# Note: 'PIL' is not available via pip2.7 on MS Windows,
# however it is available with setuptools.
}
if sys.version_info < (2, 7):
- script_deps['replicate_wiki.py'] = ['argparse']
+ script_deps['replicate_wiki'] = ['argparse']
def check_script_deps(script_name):
@@ -46,21 +46,31 @@
return True
-def runnable_script_list(scripts_path):
- """List of scripts which may be executed."""
- dir_list = os.listdir(scripts_path)
- script_list = [name[0:-3] for name in dir_list # strip .py
- if name.endswith('.py')
- and not name.startswith('_') # skip __init__.py and _*
- and check_script_deps(name)
- and name != 'login.py' # this is moved to be first
- and name != 'imageuncat.py' # this halts indefinitely
- and name != 'welcome.py' # result depends on speed
- and name != 'script_wui.py' # depends on lua compiling
- and name != 'editarticle.py' # requires a X DISPLAY
- and name != 'makecat.py' # bug 69781
- ]
- return ['login'] + script_list
+failed_dep_script_list = [name
+ for name in script_deps
+ if not check_script_deps(name)]
+
+unrunnable_script_list = [
+ 'script_wui', # depends on lua compiling
+ 'editarticle', # requires a X DISPLAY
+]
+
+deadlock_script_list = [
+ 'makecat', # bug 69781
+]
+
+script_list = (['login'] +
+ [name[0:-3] for name in os.listdir(scripts_path) # strip '.py'
+ if name.endswith('.py')
+ and not name.startswith('_') # skip __init__.py and _*
+ and name != 'login.py' # this is moved to be first
+ ]
+ )
+
+runnable_script_list = (['login'] +
+ sorted(set(script_list) -
+ set(['login']) -
+ set(unrunnable_script_list)))
script_input = {
'catall': 'q\n', # q for quit
@@ -85,6 +95,7 @@
'clean_sandbox',
'disambredir',
'imagerecat',
+ 'login',
'lonelypages',
'misspelling',
'revertbot',
@@ -130,6 +141,45 @@
'revertbot': 'Fetching new batch of contributions',
'upload': 'ERROR: Upload error',
}
+
+
+def collector(loader=unittest.loader.defaultTestLoader):
+ """Load the default tests."""
+ # Note: Raising SkipTest during load_tests will
+ # cause the loader to fallback to its own
+ # discover() ordering of unit tests.
+
+ enable_autorun_tests = (
+ os.environ.get('PYWIKIBOT2_TEST_AUTORUN', '0') == '1')
+
+ tests = (['test__login_execution'] +
+ ['test_' + name + '_execution'
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in deadlock_script_list] +
+ ['test__login_no_args'])
+
+ tests += ['test_' + name + '_no_args'
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in deadlock_script_list
+ and name not in failed_dep_script_list # no_args = execution
+ and name not in unrunnable_script_list
+ and (enable_autorun_tests or name not in auto_run_script_list)]
+
+ test_list = ['tests.script_tests.TestScript.' + name
+ for name in tests]
+
+ tests = loader.loadTestsFromNames(test_list)
+ suite = unittest.TestSuite()
+ suite.addTests(tests)
+ return suite
+
+
+def load_tests(loader=unittest.loader.defaultTestLoader,
+ tests=None, pattern=None):
+ """Load the default modules."""
+ return collector(loader)
def execute(command, data_in=None, timeout=0):
@@ -195,10 +245,12 @@
result['stderr'])
return testScript
- for script_name in runnable_script_list(scripts_path):
+ for script_name in script_list:
# force login to be the first, alphabetically, so the login
# message does not unexpectedly occur during execution of
# another script.
+ # unrunnable script tests are disabled by default in load_tests()
+
if script_name == 'login':
test_name = 'test__' + script_name + '_execution'
else:
@@ -212,6 +264,17 @@
]:
dct[test_name] = unittest.expectedFailure(dct[test_name])
dct[test_name].__doc__ = 'Test running ' + script_name + '.'
+ dct[test_name].__name__ = test_name
+
+ # Ideally all scripts should execute -help without
+ # connecting to a site. However pywikibot always
+ # logs site.live_version().
+ # TODO: make logging live_version() optional, then set
+ # dct[test_name].site = True
+ # for only the tests which dont respond to -help
+
+ if script_name in deadlock_script_list:
+ dct[test_name].__test__ = False
if script_name == 'login':
test_name = 'test__' + script_name + '_no_args'
@@ -222,6 +285,7 @@
if script_name in ['checkimages', # bug 68613
'data_ingestion', # bug 68611
'flickrripper', # bug 68606 (and deps)
+ 'script_wui', # Error on any user except DrTrigonBot
'upload', # raises custom ValueError
] or (
((config.family != 'wikipedia' or config.mylang != 'en') and script_name == 'cfd') or
@@ -232,12 +296,28 @@
'Test running ' + script_name + ' without arguments.'
dct[test_name].__name__ = test_name
+ # Disable test bt default in nosetests
+ if script_name in unrunnable_script_list + deadlock_script_list:
+ dct[test_name].__test__ = False
+
+ # TODO: Ideally any script not on the auto_run_script_list
+ # can be set as 'not a site' test, but that will require
+ # auditing all code in main() to ensure it exits without
+ # connecting to a site. There are outstanding bugs about
+ # connections during initialisation.
+ #
+ # dct[test_name].site = True
+
return type.__new__(cls, name, bases, dct)
class TestScript(PywikibotTestCase):
- """Test cases for scripts."""
+ """Test cases for scripts.
+
+ This class sets the nose 'site' attribute on each test
+ depending on whether it is in the auto_run_script_list.
+ """
__metaclass__ = TestScriptMeta
diff --git a/tests/utils.py b/tests/utils.py
index ef1a15f..07b46c8 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -9,27 +9,11 @@
#
import time
import sys
-
-if sys.version_info < (2, 7):
- # Unittest2 is a backport of python 2.7s unittest module to python 2.6
- import unittest2 as unittest
-else:
- import unittest
-
import pywikibot
+from tests import patch_request, unpatch_request, unittest
# Number of seconds each test may consume before a note is added after the test.
test_duration_warning_interval = 10
-
-
-def collector():
- # This test collector loads tests from the `tests` directory in files
- # matching the pattern `*tests.py`. This gets used by `setup.py test` when
- # running on Python 2.6 to use the unittest2 test runner instead of the
- # unittest one.
- return unittest.loader.defaultTestLoader.discover("tests", "*tests.py")
-
-from tests import patch_request, unpatch_request
class BaseTestCase(unittest.TestCase):
diff --git a/tox.ini b/tox.ini
index 9339bcc..1725c50 100644
--- a/tox.ini
+++ b/tox.ini
@@ -19,7 +19,7 @@
[testenv:nose]
setenv = PYWIKIBOT2_NO_USER_CONFIG=1
-commands = nosetests -a "!site,!net"
+commands = nosetests -a "!site,!net" tests
deps = nose
[testenv:venv]
--
To view, visit https://gerrit.wikimedia.org/r/154242
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0e18457888b428222a9dcbefcec9e1740b573aa
Gerrit-PatchSet: 10
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>