jenkins-bot has submitted this change and it was merged.
Change subject: Isolate test site object when class is not cached
......................................................................
Isolate test site object when class is not cached
The recent token changes included new tests which modified the
Site version method. Reinstating the original method creates
a pickling error on the site object, as it is cached throughout
the test suite.
This change allows a test class to have Site objects which are used
by the one test class only, and all other test class share the cached
Site objects.
Change-Id: I61474dff1b3fa53464c3a0714eb4589b935b79fa
---
M tests/aspects.py
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index ce83e5b..d6c6f18 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -388,7 +388,15 @@
for data in cls.sites.values():
if 'site' not in data:
- site = Site(data['code'], data['family'])
+ # If the test is not cached, fetch a new Site for this class
+ if not hasattr(cls, 'cached') or not cls.cached:
+ orig_sites = pywikibot._sites
+ pywikibot._sites = {}
+ site = Site(data['code'], data['family'])
+ pywikibot._sites = orig_sites
+ else:
+ site = Site(data['code'], data['family'])
+
data['site'] = site
if len(cls.sites) == 1:
--
To view, visit
https://gerrit.wikimedia.org/r/160634
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I61474dff1b3fa53464c3a0714eb4589b935b79fa
Gerrit-PatchSet: 2
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 <>