http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9836
Revision: 9836 Author: valhallasw Date: 2012-01-21 13:46:03 +0000 (Sat, 21 Jan 2012) Log Message: ----------- Update for tests / fixes for automatic test runner: * moved tests that only should be ran manually to manual/ subdir * updated test_xmlreader.py to use correct paths
Modified Paths: -------------- trunk/pywikipedia/tests/test_xmlreader.py
Added Paths: ----------- trunk/pywikipedia/tests/manual/ trunk/pywikipedia/tests/manual/test_generate_family_file.py trunk/pywikipedia/tests/manual/test_xml.py
Removed Paths: ------------- trunk/pywikipedia/tests/test_generate_family_file.py trunk/pywikipedia/tests/test_xml.py
Copied: trunk/pywikipedia/tests/manual/test_generate_family_file.py (from rev 9835, trunk/pywikipedia/tests/test_generate_family_file.py) =================================================================== --- trunk/pywikipedia/tests/manual/test_generate_family_file.py (rev 0) +++ trunk/pywikipedia/tests/manual/test_generate_family_file.py 2012-01-21 13:46:03 UTC (rev 9836) @@ -0,0 +1,20 @@ +if __name__ != "__main__": + raise Exception("generate_family_file can only be tested using the manual test runner due to monkey patching") + +import sys, os +sys.path.append(os.getcwd()) + +from generate_family_file import FamilyFileGenerator +try: + os.remove('families/test_family.py') +except Exception: + pass +FamilyFileGenerator('http://nl.wikipedia.org/wiki/Hoofdpagina', 'test').run() +os.remove('families/test_family.py') +#FamilyFileGenerator('https://nl.wikipedia.org/wiki/Hoofdpagina', 'test').run() +#os.remove('families/test_family.py') +FamilyFileGenerator('http://techessentials.org/wiki/Main_Page', 'test').run() +os.remove('families/test_family.py') +FamilyFileGenerator('http://botwiki.sno.cc/wiki/Main_Page', 'test').run() +os.remove('families/test_family.py') +
Copied: trunk/pywikipedia/tests/manual/test_xml.py (from rev 9833, trunk/pywikipedia/tests/test_xml.py) =================================================================== --- trunk/pywikipedia/tests/manual/test_xml.py (rev 0) +++ trunk/pywikipedia/tests/manual/test_xml.py 2012-01-21 13:46:03 UTC (rev 9836) @@ -0,0 +1,19 @@ +"""This is a minimal script to parse an XML file such as the sax_parse_bug.dat +dumps that interwiki.py can make if something fails. The only goal of this +program is to get a stack trace listing line number and column of the invalid +character in the XML. + +Pass this script the name of an XML file as argument. +""" +# +# (C) Rob W.W. Hooft, 2003 +# +# Distributed under the terms of the MIT license. +# +__version__ = '$Id$' +# +import sys, xml.sax, xml.sax.handler + +h = xml.sax.handler.ContentHandler() +xml.sax.parse(open(sys.argv[1], 'r'), h) +
Deleted: trunk/pywikipedia/tests/test_generate_family_file.py =================================================================== --- trunk/pywikipedia/tests/test_generate_family_file.py 2012-01-21 13:37:55 UTC (rev 9835) +++ trunk/pywikipedia/tests/test_generate_family_file.py 2012-01-21 13:46:03 UTC (rev 9836) @@ -1,20 +0,0 @@ -if __name__ != "__main__": - raise Exception("generate_family_file can only be tested using the manual test runner due to monkey patching") - -import sys, os -sys.path.append(os.getcwd()) - -from generate_family_file import FamilyFileGenerator -try: - os.remove('families/test_family.py') -except Exception: - pass -FamilyFileGenerator('http://nl.wikipedia.org/wiki/Hoofdpagina', 'test').run() -os.remove('families/test_family.py') -#FamilyFileGenerator('https://nl.wikipedia.org/wiki/Hoofdpagina', 'test').run() -#os.remove('families/test_family.py') -FamilyFileGenerator('http://techessentials.org/wiki/Main_Page', 'test').run() -os.remove('families/test_family.py') -FamilyFileGenerator('http://botwiki.sno.cc/wiki/Main_Page', 'test').run() -os.remove('families/test_family.py') -
Deleted: trunk/pywikipedia/tests/test_xml.py =================================================================== --- trunk/pywikipedia/tests/test_xml.py 2012-01-21 13:37:55 UTC (rev 9835) +++ trunk/pywikipedia/tests/test_xml.py 2012-01-21 13:46:03 UTC (rev 9836) @@ -1,19 +0,0 @@ -"""This is a minimal script to parse an XML file such as the sax_parse_bug.dat -dumps that interwiki.py can make if something fails. The only goal of this -program is to get a stack trace listing line number and column of the invalid -character in the XML. - -Pass this script the name of an XML file as argument. -""" -# -# (C) Rob W.W. Hooft, 2003 -# -# Distributed under the terms of the MIT license. -# -__version__ = '$Id$' -# -import sys, xml.sax, xml.sax.handler - -h = xml.sax.handler.ContentHandler() -xml.sax.parse(open(sys.argv[1], 'r'), h) -
Modified: trunk/pywikipedia/tests/test_xmlreader.py =================================================================== --- trunk/pywikipedia/tests/test_xmlreader.py 2012-01-21 13:37:55 UTC (rev 9835) +++ trunk/pywikipedia/tests/test_xmlreader.py 2012-01-21 13:46:03 UTC (rev 9836) @@ -5,9 +5,12 @@
import xmlreader
+import os +path = os.path.dirname(os.path.abspath(__file__) ) + class XmlReaderTestCase(unittest.TestCase): def test_XmlDumpAllRevs(self): - pages = [r for r in xmlreader.XmlDump("data/article-pear.xml", allrevisions=True).parse()] + pages = [r for r in xmlreader.XmlDump(path + "/data/article-pear.xml", allrevisions=True).parse()] self.assertEquals(4, len(pages)) self.assertEquals(u"Automated conversion", pages[0].comment) self.assertEquals(u"Pear", pages[0].title) @@ -17,7 +20,7 @@ self.assertEquals(u"Pear", pages[0].title)
def test_XmlDumpFirstRev(self): - pages = [r for r in xmlreader.XmlDump("data/article-pear.xml").parse()] + pages = [r for r in xmlreader.XmlDump(path + "/data/article-pear.xml").parse()] self.assertEquals(1, len(pages)) self.assertEquals(u"Automated conversion", pages[0].comment) self.assertEquals(u"Pear", pages[0].title) @@ -26,7 +29,7 @@ self.assertTrue(not pages[0].isredirect)
def test_XmlDumpRedirect(self): - pages = [r for r in xmlreader.XmlDump("data/article-pyrus.xml").parse()] + pages = [r for r in xmlreader.XmlDump(path + "/data/article-pyrus.xml").parse()] self.assertTrue(pages[0].isredirect)
def test_MediaWikiXmlHandler(self): @@ -35,7 +38,7 @@ def pageDone(page): pages.append(page) handler.setCallback(pageDone) - xml.sax.parse("data/article-pear.xml", handler) + xml.sax.parse(path + "/data/article-pear.xml", handler) self.assertEquals(u"Pear", pages[0].title) self.assertEquals(4, len(pages)) self.assertNotEquals("", pages[0].comment)