jenkins-bot has submitted this change and it was merged.
Change subject: Skip TestFactoryGenerator.test_regexfilter_ns
......................................................................
Skip TestFactoryGenerator.test_regexfilter_ns
This skips the test_regexfilter_ns test that takes
over 10 mins to complete due to bug T85389.
-titleregex is fetching all of the pages matching the
regex, regardless of the limit.
Change-Id: I25042dcb22d79586ddba9958a38ddddd064135f3
---
M tests/pagegenerators_tests.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 5985c58..31d0ec3 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -389,13 +389,14 @@
self.assertIsInstance(page, pywikibot.Page)
self.assertRegex(page.title().lower(), '^(.)\\1+')
- @unittest.expectedFailure
def test_regexfilter_ns(self):
+ raise unittest.SkipTest
gf = pagegenerators.GeneratorFactory()
self.assertTrue(gf.handleArg('-titleregex:.*'))
gf.handleArg('-limit:10')
gf.handleArg('-ns:1')
gen = gf.getCombinedGenerator()
+ # The code below takes due to bug T85389
pages = list(gen)
# TODO: Fix RegexFilterPageGenerator to handle namespaces other than 0
# Bug: T85389
--
To view, visit https://gerrit.wikimedia.org/r/181956
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25042dcb22d79586ddba9958a38ddddd064135f3
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Daviskr <davis(a)daviskr.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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add Generator Factory Tests
......................................................................
Add Generator Factory Tests
Added tests under TestFacoryGenerator for Allpages, Prefixing, and
RegexFilter PageGenerators. Also added a test for passing
only `-ns` to a GeneratorFactory.
The `default` for each for each tests the limit
and basic functionallity (Prefixing tests whether
the page starts with the prefix and RegexFilter
tests whether the returned pages match the regex).
The `ns` tests test whether the pages returned are in
the specified namespace.
`test_regexfilter_ns` is expected to fail due to bug T85389.
Essentially all results from `-titleregex` will have a namespace
of 0 and will return an empty generator if called with a namespace
other than 0.
Change-Id: I8a482bac50d983bb57d70468ce5bc61b2e031a81
---
M tests/pagegenerators_tests.py
1 file changed, 75 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 32f3fda..5985c58 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -349,6 +349,81 @@
"""Test pagegenerators.GeneratorFactory."""
+ def test_ns(self):
+ gf = pagegenerators.GeneratorFactory()
+ gf.handleArg('-ns:1')
+ gen = gf.getCombinedGenerator()
+ self.assertIsNone(gen)
+
+ def test_allpages_default(self):
+ gf = pagegenerators.GeneratorFactory()
+ self.assertTrue(gf.handleArg('-start:!'))
+ gf.handleArg('-limit:10')
+ gf.handleArg('-step:5')
+ gen = gf.getCombinedGenerator()
+ pages = set(gen)
+ self.assertLessEqual(len(pages), 10)
+ for page in pages:
+ self.assertIsInstance(page, pywikibot.Page)
+ self.assertEqual(page.namespace(), 0)
+
+ def test_allpages_ns(self):
+ gf = pagegenerators.GeneratorFactory()
+ self.assertTrue(gf.handleArg('-start:!'))
+ gf.handleArg('-limit:10')
+ gf.handleArg('-ns:1')
+ gen = gf.getCombinedGenerator()
+ pages = set(gen)
+ self.assertLessEqual(len(pages), 10)
+ self.assertPagesInNamespaces(gen, 1)
+
+ def test_regexfilter_default(self):
+ gf = pagegenerators.GeneratorFactory()
+ # Matches titles with the same two or more starting letters
+ self.assertTrue(gf.handleArg('-titleregex:^(.)\\1+'))
+ gf.handleArg('-limit:10')
+ gen = gf.getCombinedGenerator()
+ pages = list(gen)
+ self.assertLessEqual(len(pages), 10)
+ for page in pages:
+ self.assertIsInstance(page, pywikibot.Page)
+ self.assertRegex(page.title().lower(), '^(.)\\1+')
+
+ @unittest.expectedFailure
+ def test_regexfilter_ns(self):
+ gf = pagegenerators.GeneratorFactory()
+ self.assertTrue(gf.handleArg('-titleregex:.*'))
+ gf.handleArg('-limit:10')
+ gf.handleArg('-ns:1')
+ gen = gf.getCombinedGenerator()
+ pages = list(gen)
+ # TODO: Fix RegexFilterPageGenerator to handle namespaces other than 0
+ # Bug: T85389
+ # Below should fail
+ self.assertGreater(len(pages), 0)
+ self.assertLessEqual(len(pages), 10)
+ self.assertPagesInNamespaces(gen, 1)
+
+ def test_prefixing_default(self):
+ gf = pagegenerators.GeneratorFactory()
+ self.assertTrue(gf.handleArg('-prefixindex:a'))
+ gf.handleArg('-limit:10')
+ gf.handleArg('-step:5')
+ gen = gf.getCombinedGenerator()
+ pages = set(gen)
+ self.assertLessEqual(len(pages), 10)
+ for page in pages:
+ self.assertIsInstance(page, pywikibot.Page)
+ self.assertTrue(page.title().lower().startswith('a'))
+
+ def test_prefixing_ns(self):
+ gf = pagegenerators.GeneratorFactory(site=self.site)
+ gf.handleArg('-ns:1')
+ gf.handleArg('-prefixindex:a')
+ gf.handleArg("-limit:10")
+ gen = gf.getCombinedGenerator()
+ self.assertPagesInNamespaces(gen, 1)
+
def test_newpages_default(self):
gf = pagegenerators.GeneratorFactory(site=self.site)
gf.handleArg('-newpages')
--
To view, visit https://gerrit.wikimedia.org/r/181714
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a482bac50d983bb57d70468ce5bc61b2e031a81
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Daviskr <davis(a)daviskr.com>
Gerrit-Reviewer: Daviskr <davis(a)daviskr.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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #1849
Status: Broken
Duration: 44 minutes and 42 seconds
Commit: f3715e6 (master)
Author: Fabian Neundorf
Message: [IMPROV] Use commons for claim-type commonsMedia
The commonsMedia claim type only works for Wikimedia Commons so allowing
in theory any image repository doesn't make sense. To make it more
dynamic it's using a dictionary to exchange the conversion of the claim
value depending on the claim type. Without that it wouldn't be possible
to do the wikibase tests in dry mode because it would try to create a
Site which isn't allowed usually.
Change-Id: I727edf1120b7dc75cea72e679e16f122ac4de3ad
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/539cf6fc791d...f3715e66…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/45255003
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: Add reflinks xml tests
......................................................................
Add reflinks xml tests
Bug: T85334
Change-Id: I83ed220905763e78804ddd14be25418af8c20384
---
M scripts/reflinks.py
A tests/data/xml/article-pear-0.10.xml
A tests/data/xml/dummy-reflinks.xml
A tests/reflinks_tests.py
4 files changed, 629 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index ed7df9e..d241476 100644
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -56,8 +56,10 @@
import io
import pywikibot
+
from pywikibot import i18n, pagegenerators, textlib, xmlreader, Bot
-import noreferences
+
+from scripts import noreferences
# TODO: Convert to httlib2
if sys.version_info[0] > 2:
@@ -186,11 +188,11 @@
"""Xml generator that yields pages containing bare references."""
- def __init__(self, xmlFilename, xmlStart, namespaces):
+ def __init__(self, xmlFilename, xmlStart, namespaces, site=None):
self.xmlStart = xmlStart
self.namespaces = namespaces
self.skipping = bool(xmlStart)
- self.site = pywikibot.Site()
+ self.site = site or pywikibot.Site()
dump = xmlreader.XmlDump(xmlFilename)
self.parser = dump.parse()
diff --git a/tests/data/xml/article-pear-0.10.xml b/tests/data/xml/article-pear-0.10.xml
new file mode 100644
index 0000000..29a20ea
--- /dev/null
+++ b/tests/data/xml/article-pear-0.10.xml
@@ -0,0 +1,318 @@
+<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
+ <siteinfo>
+ <sitename>Wikipedia</sitename>
+ <dbname>enwiki</dbname>
+ <base>http://en.wikipedia.org/wiki/Main_Page</base>
+ <generator>MediaWiki 1.25wmf12</generator>
+ <case>first-letter</case>
+ <namespaces>
+ <namespace key="-2" case="first-letter">Media</namespace>
+ <namespace key="-1" case="first-letter">Special</namespace>
+ <namespace key="0" case="first-letter" />
+ <namespace key="1" case="first-letter">Talk</namespace>
+ <namespace key="2" case="first-letter">User</namespace>
+ <namespace key="3" case="first-letter">User talk</namespace>
+ <namespace key="4" case="first-letter">Wikipedia</namespace>
+ <namespace key="5" case="first-letter">Wikipedia talk</namespace>
+ <namespace key="6" case="first-letter">File</namespace>
+ <namespace key="7" case="first-letter">File talk</namespace>
+ <namespace key="8" case="first-letter">MediaWiki</namespace>
+ <namespace key="9" case="first-letter">MediaWiki talk</namespace>
+ <namespace key="10" case="first-letter">Template</namespace>
+ <namespace key="11" case="first-letter">Template talk</namespace>
+ <namespace key="12" case="first-letter">Help</namespace>
+ <namespace key="13" case="first-letter">Help talk</namespace>
+ <namespace key="14" case="first-letter">Category</namespace>
+ <namespace key="15" case="first-letter">Category talk</namespace>
+ <namespace key="100" case="first-letter">Portal</namespace>
+ <namespace key="101" case="first-letter">Portal talk</namespace>
+ <namespace key="108" case="first-letter">Book</namespace>
+ <namespace key="109" case="first-letter">Book talk</namespace>
+ <namespace key="118" case="first-letter">Draft</namespace>
+ <namespace key="119" case="first-letter">Draft talk</namespace>
+ <namespace key="446" case="first-letter">Education Program</namespace>
+ <namespace key="447" case="first-letter">Education Program talk</namespace>
+ <namespace key="710" case="first-letter">TimedText</namespace>
+ <namespace key="711" case="first-letter">TimedText talk</namespace>
+ <namespace key="828" case="first-letter">Module</namespace>
+ <namespace key="829" case="first-letter">Module talk</namespace>
+ <namespace key="2600" case="first-letter">Topic</namespace>
+ </namespaces>
+ </siteinfo>
+ <page>
+ <title>Pear</title>
+ <ns>0</ns>
+ <id>24278</id>
+ <revision>
+ <id>638548877</id>
+ <parentid>638548865</parentid>
+ <timestamp>2014-12-17T21:09:18Z</timestamp>
+ <contributor>
+ <username>ClueBot NG</username>
+ <id>13286072</id>
+ </contributor>
+ <minor/>
+ <comment>Reverting possible vandalism by [[Special:Contributions/Cutehammy|Cutehammy]] to version by Riversid. False positive? [[User:ClueBot NG/FalsePositives|Report it]]. Thanks, [[User:ClueBot NG|ClueBot NG]]. (2067875) (Bot)</comment>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text xml:space="preserve" bytes="25986">{{Redirect|Pyrus}}
+{{Other uses}}
+{{stack begin}}
+{{Taxobox
+| name = Pears
+| image = Pears.jpg
+| image_caption = [[European Pear]] branch with two pears
+| regnum = [[Plant]]ae
+| unranked_divisio = [[Angiosperms]]
+| unranked_classis = [[Eudicots]]
+| unranked_ordo = [[Rosids]]
+| ordo = [[Rosales]]
+| familia = [[Rosaceae]]
+| subfamilia = [[Amygdaloideae]]<ref name=Potter>{{cite journal | last1 = Potter | first1 = D. ''et al.'' | year = 2007 | title = Phylogeny and classification of Rosaceae | url = | journal = Plant Systematics and Evolution | volume = 266 | issue = 1–2| pages = 5–43 | doi=10.1007/s00606-007-0539-9 | last2 = Eriksson | first2 = T. | last3 = Evans | first3 = R. C. | last4 = Oh | first4 = S. | last5 = Smedmark | first5 = J. E. E. | last6 = Morgan | first6 = D. R. | last7 = Kerr | first7 = M. | last8 = Robertson | first8 = K. R. | last9 = Arsenault | first9 = M. | last10 = Dickinson | first10 = T. A. | last11 = Campbell | first11 = C. S.}} <nowiki>[Referring to the subfamily by the name "Spiraeoideae"]</nowiki></ref>
+| tribus = [[Maleae]]
+| subtribus = [[Malinae]]
+| genus = '''''Pyrus'''''
+| genus_authority = [[Carolus Linnaeus|L.]]
+| subdivision_ranks = [[Species]]
+| subdivision =
+About 30 species; see text.
+}}
+[[File:Pyrus pyrifolia.jpg|thumb|right|Many varieties, such as the [[Nashi pear]], are not "[[pear-shaped]]"]]
+{{stack end}}
+The '''pear''' is any of several tree and shrub [[species]] of [[genus]] '''''Pyrus''''' {{IPAc-en|ˈ|p|aɪ|r|ə|s}}, in the [[family]] Rosaceae. It is also the name of the [[pome|pomaceous]] fruit of these trees. Several species of pear are valued for their edible fruit, while others are cultivated as ornamental trees. The genus ''Pyrus'' is classified in subtribe [[Pyrinae]] within tribe [[Pyreae]].
+
+==Etymology==
+The English word “pear” is probably from Common West Germanic ''pera'', probably a [[loanword]] of [[Vulgar Latin]] ''pira'', the plural of ''pirum'', akin to Greek ἄπιος ''apios'' (from Mycenaean ''ápisos''),<ref>{{OEtymD|pear}}</ref> which is of Semitic origin (Aramaic/Syriac "pirâ", meaning "fruit", from the verb "pra", meaning "to beget, multiply, bear fruit"). The [[Perry (disambiguation)#Places|place name ''Perry'']] can indicate the historical presence of pear trees. The term "pyriform" is sometimes used to describe something which is pear-shaped.
+
+==Description==
+[[File:PearBlossomsCalifornia.jpg|thumb|left|Pear blossoms]]
+
+The pear is [[native plant|native]] to coastal and mildly temperate regions of the Old World, from western Europe and north Africa east right across Asia. It is a medium-sized tree, reaching {{convert|10|–|17|m|ft}} tall, often with a tall, narrow crown; a few species are [[shrub]]by.
+
+The [[leaf|leaves]] are alternately arranged, simple, {{convert|2|–|12|cm|in}} long, glossy green on some species, densely silvery-hairy in some others; leaf shape varies from broad oval to narrow lanceolate. Most pears are [[deciduous]], but one or two species in southeast Asia are [[evergreen]]. Most are cold-hardy, withstanding temperatures between {{convert|−25|C|F}} and {{convert|−40|C|F}} in winter, except for the evergreen species, which only tolerate temperatures down to about {{convert|−15|C|F}}.
+
+The [[flower]]s are white, rarely tinted yellow or pink, {{convert|2|–|4|cm|in}} diameter, and have five petals.<ref name="pearfruit">[http://web.archive.org/web/20100916180243/ht… Pear Fruit Facts Page Information]. bouquetoffruits.com</ref> Like that of the related [[apple]], the pear fruit is a [[pome]], in most wild species {{convert|1|–|4|cm|in}} diameter, but in some cultivated forms up to {{convert|18|cm|in}} long and {{convert|8|cm|in}} broad; the shape varies in most species from oblate or globose, to the classic pyriform '[[pear shaped|pear-shape]]' of the [[European pear]] with an elongated basal portion and a bulbous end.
+
+The fruit is composed of the receptacle or upper end of the flower-stalk (the so-called [[calyx (botany)|calyx]] tube) greatly dilated. Enclosed within its cellular flesh is the true fruit: five [[cartilaginous]] [[carpels]], known colloquially as the "core". From the upper rim of the receptacle are given off the five [[sepal]]s{{Vague|now you are talking about the §flower§ again|date=July 2009}}, the five [[petal]]s, and the very numerous [[stamen]]s.
+
+Pears and apples cannot always be distinguished by the form of the fruit; some pears look very much like some apples, e.g. the [[Pyrus pyrifolia|nashi pear]]. One major difference is that the flesh of pear fruit contains [[Sclereids|stone cells]] (also called "grit").
+
+==History==
+
+The [[Pomology|cultivation]] of the pear in cool [[temperate climate]]s extends to the remotest antiquity, and there is evidence of its use as a food since prehistoric times. Many traces of it have been found in the [[Lake dwelling|Swiss lake-dwelling]]s. The word “pear”, or its equivalent, occurs in all the Celtic languages, while in Slavic and other dialects, differing appellations, still referring to the same thing, are found—a diversity and multiplicity of [[nomenclature]] which led [[Alphonse de Candolle]] to infer a very ancient cultivation of the tree from the shores of the Caspian to those of the Atlantic.
+
+The pear was also cultivated by the Romans, who ate the fruits raw or cooked, just like apples.<ref name="Toussaint-Samat2009">{{cite book|author=Toussaint-Samat, Maguelonne |title=A History of Food|url=http://books.google.com/books?id=QmevzbQ0AsIC&pg=PA573|year= 2009|publisher=John Wiley & Sons|isbn=978-1-4443-0514-2|page=573}}</ref> [[Pliny's Natural History]] recommended stewing them with honey and noted three dozen varieties. The Roman cookbook attributed to [[Apicius]], ''[[De re coquinaria]]'', has a recipe for a spiced, stewed-pear ''patina'', or soufflé.<ref>{{cite book|title=Apicius (with an introd. and an Engl. transl.)|year=2006|publisher=Prospect Books|location=Blackawton, Totnes|isbn=978-1-903018-13-2|page=IV.2.35 |author=Grainger, Sally and Grocock, Christopher}}</ref>
+
+A certain race of pears, with white down on the [[Epidermis (botany)|under surface]] of their leaves, is supposed to have originated from ''P. nivalis'', and their fruit is chiefly used in France in the manufacture of [[perry]] (see also [[cider]]). Other small-fruited pears, distinguished by their early ripening and apple-like fruit, may be referred to as ''P. cordata'', a species found wild in western France and southwestern England. Pears have been cultivated in China for approximately 3000 years.
+
+The [[genus]] is thought to have originated in present-day western China in the foothills of the [[Tian Shan]], a mountain range of Central Asia, and to have spread to the north and south along mountain chains, evolving into a diverse group of over 20 widely recognized primary species {{Citation needed|date=December 2009}}. The enormous number of varieties of the cultivated [[European pear]] (''Pyrus communis'' subsp. ''communis''), are without doubt derived from one or two wild [[subspecies]] (''P. communis'' subsp. ''pyraster'' and ''P. communis'' subsp. ''caucasica''), widely distributed throughout Europe, and sometimes forming part of the natural vegetation of the forests. Court accounts of Henry III of England record pears shipped from La Rochelle-Normande and presented to the King by the Sheriffs of the City of London. The French names of pears grown in English medieval gardens suggest that their reputation, at the least, was French; a favored variety in the accounts was named for Saint Rule or Regul', Bishop of Senlis.<ref name=Cecil>{{cite book|author=Cecil, Evelyn |title=A History of Gardening in England|url=http://books.google.com/books?id=Fk4KTrvZ8nMC|year= 2006|publisher=Kessinger Publishing|isbn=978-1-4286-3680-4|pages=35 ff}}</ref>
+
+Asian species with medium to large edible fruit include ''P. pyrifolia'', ''P. ussuriensis'', ''P. × bretschneideri'', ''P. × sinkiangensis'', and ''P. pashia.'' Other small-fruited species are frequently used as [[rootstock]]s for the cultivated forms.
+
+===Major recognized taxa===
+[[File:Bradford 9288.JPG|right|thumb|[[Callery Pear]]s in flower]]
+
+{|
+|- valign=top
+|
+*''[[Pyrus amygdaliformis]]''—Almond-leaved pear
+*''[[Pyrus armeniacifolia]]''—Apricot-leaved pear
+*''[[Pyrus boissieriana]]''
+*''[[Pyrus bourgaeana]]''—Iberian pear
+*''[[Pyrus × bretschneideri]]''—Chinese white pear; also classified as a subspecies of ''Pyrus pyrifolia''
+*''[[Callery Pear|Pyrus calleryana]]''—Callery pear
+*''[[Pyrus communis]]'' – European pear
+**''[[Pyrus communis]]'' subsp. ''communis''—European pear (cultivars include [[d'Anjou|Beurre d'Anjou]], [[Williams pear|Bartlett]] and [[Bosc Pear|Beurre Bosc]])
+**''Pyrus communis '' subsp. ''caucasica'' ([[syn.]] ''P. caucasica'')
+**''[[Pyrus pyraster|Pyrus communis subsp. pyraster]]'' — Wild European Pear ([[syn.]] ''(Pyrus pyraster)'')
+*''[[Pyrus cordata]]''—Plymouth pear
+*''[[Pyrus cossonii]]''—Algerian pear
+*''[[Pyrus dimorphophylla]]''
+*''[[Pyrus elaeagrifolia]]''—Oleaster-leaved pear
+*''[[Pyrus fauriei]]''
+*''[[Pyrus gharbiana]]''
+*''[[Pyrus glabra]]''
+*''Pyrus hondoensis''
+*''[[Pyrus koehnei]]''—Evergreen pear of southern China and Taiwan
+*''[[Pyrus korshinskyi]]''
+*''[[Pyrus mamorensis]]''
+*''[[Pyrus nivalis]]''—Snow pear
+*''[[Pyrus pashia]]''—Afghan pear
+*''[[Pyrus ×phaeocarpa]]''
+*''[[Pyrus pseudopashia]]''
+*''[[Pyrus pyrifolia]]''—Nashi pear, ''Sha Li''; tree species native to China, Japan, and Korea, also known as the Asian pear
+*''[[Pyrus regelii]]''
+*''[[Pyrus salicifolia]]''—Willow-leaved pear
+*''[[Pyrus × serrulata]]''
+*''[[Pyrus × sinkiangensis]]''—thought to be an interspecific hybrid between ''P. ''×''bretschneideri'' and ''Pyrus communis''
+*''[[Pyrus syriaca]]''—Syrian pear
+*''[[Pyrus ussuriensis]]''—Siberian pear (also known as the '''Ussurian pear''', '''Harbin pear''', and '''Manchurian pear''')
+*''[[Pyrus xerophila]]''
+|}
+
+==Cultivation==
+[[File:Pear tree in Hamedan Iran.jpg|thumb|Pear tree in [[Hamedan]], [[Iran]]]]
+[[File:204VicarWinkfield.jpg|thumb|Vicar of Winkfield pear, a heritage variety, no longer commonly found, [[British Columbia]], [[Canada]]]]
+
+According to Pear Bureau Northwest, about 3000 known varieties of pears are grown worldwide.<ref>{{cite web|url=http://usapears.com/Recipes%20And%20Lifestyle/Now%20Serving/Pears%2… |title=Pear Varieties |publisher=Usapears.com |date= |accessdate=2014-08-09}}</ref>
+The pear is normally propagated by [[grafting]] a selected variety onto a [[rootstock]], which may be of a pear variety or [[quince]]. Quince rootstocks produce smaller trees, which is often desirable in commercial orchards or domestic gardens. For new varieties the flowers can be [[Cross-breeding|cross-bred]] to preserve or combine desirable traits. The fruit of the pear is produced on spurs, which appear on shoots more than one year old.<ref>RHS Fruit, Harry Baker, ISBN 1 85732 905 8, pp100-101.</ref>
+
+Three species account for the vast majority of edible fruit production, the [[European pear]] ''Pyrus communis'' subsp. ''communis'' cultivated mainly in Europe and North America, the Chinese white pear (''bai li'') ''Pyrus ×bretschneideri'', and the [[Nashi pear]] ''Pyrus pyrifolia'' (also known as Asian pear or apple pear), both grown mainly in eastern Asia. There are thousands of [[cultivar]]s of these three species. A species grown in western China, ''P. sinkiangensis'', and ''P. pashia'', grown in southern China and south Asia, are also produced to a lesser degree.
+
+Other species are used as [[rootstock]]s for European and Asian pears and as [[ornamental plant|ornamental trees]]. The Manchurian or Ussurian Pear, ''[[Pyrus ussuriensis]]'' (which produces [[unpalatable|unpalatable fruit]]) has been crossed with ''Pyrus communis'' to breed hardier pear cultivars. The Bradford pear (''[[Pyrus calleryana]]'' 'Bradford') in particular has become widespread in North America, and is used only as an ornamental tree, as well as a blight-resistant rootstock for ''Pyrus communis'' fruit orchards. The Willow-leaved pear (''[[Pyrus salicifolia]]'') is grown for its attractive, slender, densely silvery-hairy leaves.
+
+The following [[cultivars]] have gained the [[Royal Horticultural Society]]'s [[Award of Garden Merit]]:-
+{|
+|- valign=top
+|
+*'Beth'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=1581 |title=RHS Plant Selector Pyrus communis 'Beth' (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>
+*'Concorde'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=1582 |title=RHS Plant Selector Pyrus communis 'Concorde' PBR (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>
+*'Conference'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=1583 |title=RHS Plant Selector Pyrus communis 'Conference' (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|
+*'Joséphine de Malines'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=5823 |title=RHS Plant Selector Pyrus communis 'Joséphine de Malines' (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+*'Louise Bonne of Jersey'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=5995 |title=RHS Plant Selector Pyrus communis 'Louise Bonne of Jersey' (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>
+*'Onward'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=4517 |title=RHS Plant Selector Pyrus communis 'Onward' (D) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>
+|
+*'Williams' Bon Chrétien'<ref>{{cite web|url=http://apps.rhs.org.uk/plantselector/plant?plantid=1584 |title=RHS Plant Selector Pyrus communis 'Williams' Bon Chrétien' (D/C) AGM / RHS Gardening |publisher=Apps.rhs.org.uk |date= |accessdate=2013-03-14}}</ref>
+|}
+
+===Harvest===
+Summer and autumn [[cultivar]]s of ''Pyrus communis'', being [[climacteric fruits]], are gathered before they are fully ripe, while they are still green, but snap off when lifted. In the case of the 'Passe Crassane', long the favored winter pear in France, the crop is traditionally gathered at three different times: the first a fortnight or more before it is ripe, the second a week or ten days after that, and the third when fully ripe. The first gathering will come into eating last, and thus the season of the fruit may be considerably prolonged.
+
+Nashi pears are allowed to ripen on the tree.
+
+===Diseases and pests===
+{{Main|List of pear diseases|List of Lepidoptera that feed on pear trees}}
+
+==Production==
+[[File:2005pear and quince.svg|300px|thumb|Pear and [[quince]] output in 2005]]
+{| class="sortable wikitable" style="float:left;
+|+ Top ten pear producers <br />(in metric tons)
+!Rank
+!Country
+!2009
+!2010
+!2011
+|-
+| 1 || {{CHN}} || 14,416,430 || 15,231,858 || 15,945,013
+|-
+| 2 || {{ITA}} || 872,368 || 736,646 || 926,542
+|-
+| 3 || {{USA}} || 868,357 || 738,085 || 876,086
+|-
+| 4 || {{ARG}} || 700,000 || 704,242 || 691,270
+|-
+| 5 || {{ESP}} || 463,969 || 476,686 || 502,234
+|-
+| 6 || {{TUR}} || 384,244 || 380,003 || 386,382
+|-
+| 7 || {{ZAF}} || 340,088 || 368,495 || 350,527
+|-
+| 8 || {{NLD}} || 295,000 || 274,000 || 336,000
+|-
+| 9 || {{IND}} || 308,487 || 336,049 || 334,774
+|-
+| 10 || {{JPN}} || 351,500 || 284,900 || 312,800
+|- style="background:#ccc;"
+| — || ''World'' || 20,888,647 || 22,731,087 || 22,511,100
+|-
+|colspan=5 | ''Source: [[FAO|UN Food & Agriculture Organization]]'' <ref>{{cite web|url=http://faostat.fao.org/site/339/default.aspx|publisher= [[FAO|UN Food & Agriculture Organization]]|title=Production of Pears by countries|year=2011|accessdate=2013-08-26}}</ref>
+|}
+
+==Storage==
+Pears may be stored at room temperature until ripe.<ref name=cpma>[http://web.archive.org/web/20100225202814/http://www.cpma.ca/… Canadian Produce Marketing Association > Home Storage Guide for Fresh Fruits & Vegetables]. cpma.ca</ref> Pears are ripe when the flesh around the stem gives to gentle pressure.<ref name=cpma/> Ripe pears are optimally stored refrigerated, uncovered in a single layer, where they have a shelf life of 2 to 3 days.<ref name=cpma/>
+
+==Uses==
+[[File:Pyrus communis gestoofde stoofpeer Gieser Wildeman.jpg|right|thumb|''Gieser Wildeman'' simmered in red wine.]]
+Pears are consumed fresh, canned, as [[juice]], and [[dried fruit|dried]]. The juice can also be used in [[Jelly (fruit preserves)|jellies]] and [[jam]]s, usually in combination with other fruits or berries. Fermented pear juice is called [[perry]] or pear cider.
+
+Pears ripen at room temperature. They will [[ethylene|ripen faster]] if placed next to [[banana]]s in a fruit bowl.<ref>{{cite web |url= http://extension.oregonstate.edu/gardening/pears-can-be-ripened-perfection |title=Pears can be ripened to perfection |work=extension.oregonstate.edu |year=2011 |author= Scott, Judy and Sugar, David |accessdate=August 30, 2011}}</ref> Refrigeration will slow further ripening. Pear Bureau Northwest offers tips on ripening and judging ripeness: Although the skin on Bartlett pears changes from green to yellow as they ripen, most varieties show little color change as they ripen. Because pears ripen from the inside out, the best way to judge ripeness is to "Check the Neck": apply gentle thumb pressure to the neck or stem end of the pear. If it yields to gentle pressure, then the pear is ripe, sweet, and juicy. If it is firm, leave the pear at room temperature and check the neck daily for ripeness.<ref>{{cite web|url=http://www.usapears.org/Recipes%20And%20Lifestyle/Culinary%20Corner… |title=Pear Bureau Northwest |publisher=Usapears.org |date= |accessdate=2013-03-14}}</ref>
+
+The culinary or cooking pear is green but dry and hard, and only edible after several hours of cooking. Two Dutch cultivars are "Gieser Wildeman" (a sweet variety) and "Saint Remy" (slightly sour).<ref name="Koene2005">{{cite book|author=Koene, A. |title=Food Shopper's Guide to Holland: A Comprehensive Review of the Finest Local and International Food Products in the Dutch Marketplace|url=http://books.google.com/books?id=UgieKy9LsBAC&pg=PA79|y… 2005|publisher=Eburon Uitgeverij B.V.|isbn=978-90-5972-092-3|page=79}}</ref>
+
+Pear [[wood]] is one of the preferred materials in the manufacture of high-quality [[woodwind]] instruments and [[furniture]]. It is also used for wood carving, and as a [[firewood]] to produce aromatic smoke for smoking meat or [[tobacco]]. Pear wood is valued for kitchen spoons, scoops and stirrers, as it does not contaminate food with color, flavor or smell, and resists warping and splintering despite repeated soaking and drying cycles. Lincoln<ref name="Lincoln, William 1986 pp. 33, 207">Lincoln, William (1986). ''World Woods in Color''. Fresno, California, USA: Linden Publishing Co. Inc. pp. 33, 207. ISBN 0-941936-20-1.</ref> describes it as "a fairly tough, very stable wood... (used for) carving... brushbacks, umbrella handles, measuring instruments such as set squares and T-squares... recorders... violin and guitar fingerboards and piano keys... decorative veneering." Pearwood is the favored wood for architect's rulers because it does not warp. It is similar to the wood of its relative, the apple tree, ''Pyrus malus'' (also called ''[[Malus domestica]]'') and used for many of the same purposes.<ref name="Lincoln, William 1986 pp. 33, 207"/>
+
+Pear leaves were smoked in Europe before tobacco was introduced.<ref>[http://info-tabac.noname.fr/histoire-du-tabac.html Info Tabac: histoire du tabac], accessed 3 June 2010. {{fr icon}}</ref><ref>Dautzenberg, Bertrand [http://web.archive.org/web/20080208164528/http://tabac-net.aphp.fr/tab-conn… Epidémiologie des maladies liées au tabac]. tabac-net.aphp.fr {{fr icon}}</ref>
+
+==Health benefits==
+
+{{stack begin}}
+{{nutritional value
+| name=Pears, raw
+| image=[[File:Alexander Lucas 10.10.10.jpg|center|thumb|<center>Pear, 'Alexander Lucas'</center>]]
+| kJ=239
+| protein=0.36 g
+| fat=0.14 g
+| carbs=15.23 g
+| fiber=3.1 g
+| sugars=9.75 g
+| calcium_mg=9
+| iron_mg=0.18
+| magnesium_mg=7
+| phosphorus_mg=12
+| potassium_mg=116
+| sodium_mg=1
+| zinc_mg=0.1
+| manganese_mg=0.048
+| vitC_mg=4.3
+| thiamin_mg=0.012
+| riboflavin_mg=0.026
+| niacin_mg=0.161
+| pantothenic_mg=0.049
+| vitB6_mg=0.029
+| folate_ug=7
+| choline_mg=5.1
+| vitE_mg=0.12
+| vitK_ug=4.4
+| source_usda = 1
+| note=[http://ndb.nal.usda.gov/ndb/search/list?qlookup=09252&format=Full Link to USDA Database entry]
+}}
+{{stack end}}
+
+Pears are a good source of [[dietary fiber]] and a good source of [[vitamin C]]. Most of the vitamin C, as well as the dietary fiber, is contained within the skin of the fruit.<ref>{{cite book|author=Balch, Phyllis A. |title=Prescription for Dietary Wellness|url=http://books.google.com/books?id=Z_kueEFK0f0C&pg=PA67|year…
+
+Pears are less [[allergenic]] than many other fruits, and pear juice is therefore sometimes used as the first juice introduced to infants.<ref>{{cite web |url = http://www.freediets.com/fruits-vegetables/the-wonder-of-pears |title = The wonder of pears |publisher = FreeDiets }}</ref> However, caution is recommended for all fruit juice consumption by infants, as studies have suggested a link between excessive fruit juice consumption and reduced nutrient intake, as well as a tendency towards obesity.<ref>{{cite book|author=Samour, Patricia Queen; Helm, Kathy King and Lang, Carol E. |title=Handbook of Pediatric Nutrition|url=http://books.google.com/books?id=1j_Tn-iXbMwC&pg=PA89|yea… & Bartlett Learning|isbn=978-0-7637-3305-6|pages=89–}}</ref> Pears are low in [[salicylates]] and [[benzoic acid|benzoates]], so are recommended in exclusion diets for allergy sufferers.<ref>{{cite journal|url=http://www.sswahs.nsw.gov.au/rpa/allergy/research/excldiet.pdf|title=An Australian exclusion diet|year= 1978|pmid=661687|journal=The Medical Journal of Australia |volume=1|pages=290–292|last1=Gibson|first1=AR|last2=Clancy|first2=RL|issue=5}}</ref> Along with [[domestic sheep|lamb]] and [[rice]], pears may form part of the strictest exclusion diet for allergy sufferers.<ref>{{cite web|url=http://www.allergy-clinic.co.uk/food_allergy_for_public.htm |title=A Guide to Suspected Food Allergy|work=Surrey Allergy Clinic, UK|author=Morris, A. |year=2008|accessdate=2013-03-14}}</ref>
+
+Most of the fiber is insoluble, making pears a good laxative.<ref>{{cite web|url=http://www.mayoclinic.com/health/infant-constipation/AN01089 |title=Infant constipation: How is it treated? |publisher=MayoClinic.com |date=2011-05-21 |accessdate=2012-08-17}}</ref>
+
+==Cultural references==
+
+Pears grow in the sublime [[orchard]] of [[Alcinous]], in ''[[Odyssey]]'' vii: "Therein grow trees, tall and luxuriant, pears and [[pomegranate]]s and [[apple]]-trees with their bright fruit, and sweet [[ficus|fig]]s, and luxuriant [[olive]]s. Of these the fruit perishes not nor fails in [[winter]] or in summer, but lasts throughout the year."
+
+'A [[Partridge]] in a Pear Tree' is the first gift in [[The Twelve Days of Christmas (song)|"The Twelve Days of Christmas"]] [[cumulative song]], this verse is repeated twelve times in the song.
+
+The pear tree was an object of particular veneration (as was the [[Walnut]]) in the [[Tree worship]] of the [[Nakh peoples]] of the [[North Caucasus]] - see [[Vainakh mythology]] and see also [[Ingushetia]] - the best-known of the Vainakh peoples today being the [[Chechens]] of [[Chechnya]] in the [[Russian Federation]].
+Pear and walnut trees were held to be the sacred abodes of beneficent spirits in pre-Islamic Chechen religion and,for this reason,it was forbidden to fell them.<ref>''The Chechens: A Handbook'' by Jaimoukha,Amjad. Published by Psychology Press 2005. ISBN 978-0-415-32328-4.</ref>
+
+==See also==
+* [[List of culinary fruits]]
+* [[Pear-shaped]]
+
+==References==
+{{reflist|3}}
+{{EB1911}}
+
+==External links==
+{{Sister project links|wikt=pear|commons=Category:Pears|v=no|s=no|n=no|b=Horticulture/Pyrus|species=Pyrus}}
+{{Cookbook|Pear}}
+* [http://www.calpear.com/recipes/default.aspx California Pear Recipes] – Over one hundred pear recipes from California Pears.
+* [http://www.dpi.nsw.gov.au/agriculture/horticulture/pomes/euro-varieties European pear varieties] – description of Australian commercial pears
+* [http://www.mythencyclopedia.com/Fi-Go/Fruit-in-Mythology.html Fruit in mythology] – Symbolism of pears
+* [http://botany.metalibrary.net/books/bartrum/pearsandplums Handbook of Practical Gardening] – Gardening information on pears.
+* [http://www.hort.purdue.edu/newcrop/pearinhistory.pdf "The Pear in History, Literature, Popular Culture, and Art"]
+* [http://www.pearpanache.com Pear Panache] – a collection of pear recipes for chefs and by chefs
+* [http://www.usapears.org/Recipes%20And%20Lifestyle/Now%20Serving/Recipes.aspx Pear Recipes] – collection of pear recipes from Pear Bureau Northwest
+* [http://www.calpear.com/our-fruit/varieties-availability.aspx Pear Varieties] – Information about pear varieties grown in California.
+* [http://www.uga.edu/fruit/pear.html University of Georgia Pear Page] – History of cultivation and commerce.
+* [http://www.cirrusimage.com/tree_wild_pear.htm Wild Pear, ''Pyrus pyraster''] – Diagnostic photos, [[Morton Arboretum]] specimens
+* [http://extension.oregonstate.edu/gardening/node/413 When to pick and how to ripen pears to perfection; Oregon State University Extension Service; July 2009]
+{{Pyrus}}
+
+[[Category:Pears| ]]
+[[Category:Flora of Asia]]
+[[Category:Flora of Europe]]
+[[Category:Pyrus| ]]</text>
+ <sha1>1ywwm7o751gkr3fj9l7rqpl0s8o87b1</sha1>
+ </revision>
+ </page>
+</mediawiki>
diff --git a/tests/data/xml/dummy-reflinks.xml b/tests/data/xml/dummy-reflinks.xml
new file mode 100644
index 0000000..3522e82
--- /dev/null
+++ b/tests/data/xml/dummy-reflinks.xml
@@ -0,0 +1,82 @@
+<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
+ <siteinfo>
+ <sitename>Wikipedia</sitename>
+ <dbname>enwiki</dbname>
+ <base>http://en.wikipedia.org/wiki/Main_Page</base>
+ <generator>MediaWiki 1.25wmf12</generator>
+ <case>first-letter</case>
+ <namespaces>
+ <namespace key="-2" case="first-letter">Media</namespace>
+ <namespace key="-1" case="first-letter">Special</namespace>
+ <namespace key="0" case="first-letter" />
+ <namespace key="1" case="first-letter">Talk</namespace>
+ <namespace key="2" case="first-letter">User</namespace>
+ <namespace key="3" case="first-letter">User talk</namespace>
+ <namespace key="4" case="first-letter">Wikipedia</namespace>
+ <namespace key="5" case="first-letter">Wikipedia talk</namespace>
+ <namespace key="6" case="first-letter">File</namespace>
+ <namespace key="7" case="first-letter">File talk</namespace>
+ <namespace key="8" case="first-letter">MediaWiki</namespace>
+ <namespace key="9" case="first-letter">MediaWiki talk</namespace>
+ <namespace key="10" case="first-letter">Template</namespace>
+ <namespace key="11" case="first-letter">Template talk</namespace>
+ <namespace key="12" case="first-letter">Help</namespace>
+ <namespace key="13" case="first-letter">Help talk</namespace>
+ <namespace key="14" case="first-letter">Category</namespace>
+ <namespace key="15" case="first-letter">Category talk</namespace>
+ <namespace key="100" case="first-letter">Portal</namespace>
+ <namespace key="101" case="first-letter">Portal talk</namespace>
+ <namespace key="108" case="first-letter">Book</namespace>
+ <namespace key="109" case="first-letter">Book talk</namespace>
+ <namespace key="118" case="first-letter">Draft</namespace>
+ <namespace key="119" case="first-letter">Draft talk</namespace>
+ <namespace key="446" case="first-letter">Education Program</namespace>
+ <namespace key="447" case="first-letter">Education Program talk</namespace>
+ <namespace key="710" case="first-letter">TimedText</namespace>
+ <namespace key="711" case="first-letter">TimedText talk</namespace>
+ <namespace key="828" case="first-letter">Module</namespace>
+ <namespace key="829" case="first-letter">Module talk</namespace>
+ <namespace key="2600" case="first-letter">Topic</namespace>
+ </namespaces>
+ </siteinfo>
+ <page>
+ <title>Fake page</title>
+ <ns>0</ns>
+ <id>12345</id>
+ <revision>
+ <id>123456789</id>
+ <parentid>123456788</parentid>
+ <timestamp>2014-12-24T01:01:01Z</timestamp>
+ <contributor>
+ <username>John Vandenberg</username>
+ <id>31009137</id>
+ </contributor>
+ <minor/>
+ <comment>Foo</comment>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text xml:space="preserve" bytes="1"><ref>http://example.com/</ref></text>
+ <sha1>1ywwm7o751gkr3fj9l7rqpl0s8o87b1</sha1>
+ </revision>
+ </page>
+ <page>
+ <title>Talk:Fake page</title>
+ <ns>1</ns>
+ <id>54321</id>
+ <revision>
+ <id>987654321</id>
+ <parentid>987654320</parentid>
+ <timestamp>2014-12-24T01:01:02Z</timestamp>
+ <contributor>
+ <username>John Vandenberg</username>
+ <id>31009137</id>
+ </contributor>
+ <minor/>
+ <comment>Lets discuss foo</comment>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text xml:space="preserve" bytes="1"><ref>http://talk.example.com/</ref></text>
+ <sha1>1ywwm7o751gkr3fj9l7rqpl0s8o87b2</sha1>
+ </revision>
+ </page>
+</mediawiki>
diff --git a/tests/reflinks_tests.py b/tests/reflinks_tests.py
new file mode 100644
index 0000000..d5dda0a
--- /dev/null
+++ b/tests/reflinks_tests.py
@@ -0,0 +1,224 @@
+# -*- coding: utf-8 -*-
+"""Tests for reflinks script."""
+#
+# (C) Pywikibot team, 2014
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+
+import os
+
+import pywikibot
+
+from scripts.reflinks import XmlDumpPageGenerator, ReferencesRobot, main
+
+from tests import _data_dir
+from tests.aspects import unittest, TestCase
+
+_xml_data_dir = os.path.join(_data_dir, 'xml')
+
+
+class TestXMLPageGenerator(TestCase):
+
+ """Test XML Page generator."""
+
+ family = 'wikipedia'
+ code = 'en'
+
+ dry = True
+
+ def test_non_bare_ref_urls(self):
+ """Test pages without bare references are not processed."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'article-pear-0.10.xml'),
+ xmlStart=u'Pear',
+ namespaces=[0, 1],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertEqual(len(pages), 0)
+
+ def test_simple_bare_refs(self):
+ """Test simple bare references in multiple namespaces."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake page',
+ namespaces=[0, 1],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ def test_namespace_empty_list(self):
+ """Test namespaces=[] processes all namespaces."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake page',
+ namespaces=[],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_namespace_None(self):
+ """Test namespaces=None processes all namespaces."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake page',
+ namespaces=None,
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_namespace_string_ids(self):
+ """Test namespaces with ids as string."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake page',
+ namespaces=["0", "1"],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ def test_namespace_names(self):
+ """Test namespaces with namespace names."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake page',
+ namespaces=["Talk"],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Talk:Fake page', ),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_start_with_underscore(self):
+ """Test with underscore in start page title."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=u'Fake_page',
+ namespaces=[0, 1],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ def test_without_start(self):
+ """Test without a start page title."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart=None,
+ namespaces=[0, 1],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_start_prefix(self):
+ """Test with a prefix as a start page title."""
+ gen = XmlDumpPageGenerator(
+ xmlFilename=os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ xmlStart='Fake',
+ namespaces=[0, 1],
+ site=self.get_site())
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+
+class TestReferencesBotConstructor(TestCase):
+
+ """Test reflinks with non-write patching (if the testpage exists)."""
+
+ family = 'wikipedia'
+ code = 'en'
+
+ def setUp(self):
+ super(TestReferencesBotConstructor, self).setUp()
+ self._original_constructor = ReferencesRobot.__init__
+ self._original_run = ReferencesRobot.run
+ ReferencesRobot.__init__ = dummy_constructor
+ ReferencesRobot.run = lambda self: None
+ self.original_family = pywikibot.config.family
+ self.original_code = pywikibot.config.mylang
+ pywikibot.config.family = self.family
+ pywikibot.config.mylang = self.code
+
+ def tearDown(self):
+ ReferencesRobot.__init__ = self._original_constructor
+ ReferencesRobot.run = self._original_run
+ pywikibot.config.family = self.original_family
+ pywikibot.config.mylang = self.original_code
+ super(TestReferencesBotConstructor, self).tearDown()
+
+ def test_xml_simple(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'))
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ def test_xml_one_namespace(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:1')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Talk:Fake page', ),
+ site=self.get_site())
+
+ def test_xml_multiple_namespace_ids(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:0', '-namespace:1', '-xmlstart:Fake page')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_xml_multiple_namespace_ids_2(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:0,1', '-xmlstart:Fake page')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Fake page', u'Talk:Fake page'),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_xml_start_prefix(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:1', '-xmlstart:Fake')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Talk:Fake page', ),
+ site=self.get_site())
+
+ @unittest.expectedFailure
+ def test_xml_start_underscore(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:1', '-xmlstart:Fake_page')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Talk:Fake page', ),
+ site=self.get_site())
+
+ def test_xml_namespace_name(self):
+ main('-xml:' + os.path.join(_xml_data_dir, 'dummy-reflinks.xml'),
+ '-namespace:Talk', '-xmlstart:Fake page')
+ gen = self.constructor_args[0]
+ pages = list(gen)
+ self.assertPagelistTitles(pages, (u'Talk:Fake page', ),
+ site=self.get_site())
+
+
+def dummy_constructor(self, *args, **kwargs):
+ TestReferencesBotConstructor.constructor_args = args
+ TestReferencesBotConstructor.constructor_kwargs = kwargs
+
+
+if __name__ == "__main__":
+ unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/181719
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I83ed220905763e78804ddd14be25418af8c20384
Gerrit-PatchSet: 5
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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #1846
Status: Passed
Duration: 37 minutes and 39 seconds
Commit: 05531e5 (master)
Author: Anshoe
Message: Changed encoding format
Flickrripper.py threw a traceback while testing it on a local machine due
to lack of mentioning of the codec type on line 274. Fixed
Change-Id: I346f8c9824cf27fca6999e1270bd0108855c9f93
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/bb850121bd73...05531e5e…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/45224251
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: Changed encoding format
......................................................................
Changed encoding format
Flickrripper.py threw a traceback while testing it on a local machine due
to lack of mentioning of the codec type on line 274. Fixed
Change-Id: I346f8c9824cf27fca6999e1270bd0108855c9f93
---
M pywikibot/version.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 028039a..2229075 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -14,6 +14,7 @@
import time
import datetime
import subprocess
+import codecs
import pywikibot.config2 as config
@@ -270,7 +271,7 @@
mtime = None
fn = os.path.join(_program_dir, filename)
if os.path.exists(fn):
- with open(fn, 'r') as f:
+ with codecs.open(fn, 'r', "utf-8") as f:
for line in f.readlines():
if line.find('__version__') == 0:
exec(line)
--
To view, visit https://gerrit.wikimedia.org/r/181888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I346f8c9824cf27fca6999e1270bd0108855c9f93
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Anshoe <contactanshumanagarwal(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 <>