changeset 1736:af5b4eab796c

Automated merge with http://hg.moinmo.in/moin/2.0
author Cheer Xiao <xiaqqaix@gmail.com>
date Sat, 25 Aug 2012 17:09:09 +0800
parents d4f76b82aa84 (diff) 86c2c69421ef (current diff)
children 7d258c74032d
files
diffstat 5 files changed, 29 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sat Aug 25 17:07:45 2012 +0800
+++ b/MoinMoin/apps/frontend/views.py	Sat Aug 25 17:09:09 2012 +0800
@@ -1770,6 +1770,8 @@
     :rtype: list
     :returns: list of matching item names, sorted by rank
     """
+    if not item_names:
+        return []
     # Match using case insensitive matching
     # Make mapping from lower item names to item names.
     lower = {}
@@ -1782,7 +1784,7 @@
 
     # Get all close matches
     all_matches = difflib.get_close_matches(item_name.lower(), lower.keys(),
-                                            len(lower), cutoff=0.6)
+                                            n=len(lower), cutoff=0.6)
 
     # Replace lower names with original names
     matches = []
--- a/MoinMoin/converter/_tests/test_moinwiki_in_out.py	Sat Aug 25 17:07:45 2012 +0800
+++ b/MoinMoin/converter/_tests/test_moinwiki_in_out.py	Sat Aug 25 17:09:09 2012 +0800
@@ -10,7 +10,7 @@
 
 
 import pytest
-pytest.skip("too much brokenness here, please help fixing this") # XXX TODO
+# failing tests are commented out and need to be fixed XXX TODO
 
 import re
 
@@ -50,7 +50,7 @@
             (u"~-smaller-~\n", '~-smaller-~\n'),
             (u"^super^script\n", '^super^script\n'),
             (u",,sub,,script\n", ',,sub,,script\n'),
-            (u"## comment\n", "## comment\n"),
+            # (u"## comment\n", "## comment\n"), # can not work -- "## comments" are not pushed to DOM
             (u"#ANY any", "#ANY any\n"),
         ]
         for i in data:
@@ -59,7 +59,7 @@
     def test_macros(self):
         data = [
             (u"<<Anchor(anchorname)>>", '<<Anchor(anchorname)>>\n'),
-            (u"<<MonthCalendar(,,12)>>", '<<MonthCalendar(,,12)>>\n'),
+            # (u"<<MonthCalendar(,,12)>>", '<<MonthCalendar(,,12)>>\n'), # MonthCalendar macro not implemented
             (u"<<FootNote(test)>>", "<<FootNote(test)>>\n"),
             (u"<<TableOfContents(2)>>", "<<TableOfContents(2)>>\n"),
             (u"<<TeudView()>>", "<<TeudView()>>\n"),
@@ -71,8 +71,8 @@
         data = [
             (u"{{{#!wiki comment/dotted\nThis is a wiki parser.\n\nIts visibility gets toggled the same way.\n}}}", u"{{{#!wiki comment/dotted\nThis is a wiki parser.\n\nIts visibility gets toggled the same way.\n}}}\n"),
             (u"{{{#!wiki red/solid\nThis is wiki markup in a '''div''' with __css__ `class=\"red solid\"`.\n}}}", "{{{#!wiki red/solid\nThis is wiki markup in a '''div''' with __css__ `class=\"red solid\"`.\n}}}\n"),
-            (u"{{{#!creole(class=\"par: arg para: arga\" style=\"st: er\")\n... **bold** ...\n}}}", u"{{{#!creole(style=\"st: er\" class=\"par: arg para: arga\")\n... **bold** ...\n}}}\n"),
-            (u"#format creole\n... **bold** ...\n", "#format creole\n... **bold** ...\n"),
+            # (u"{{{#!creole(class=\"par: arg para: arga\" style=\"st: er\")\n... **bold** ...\n}}}", u"{{{#!creole(style=\"st: er\" class=\"par: arg para: arga\")\n... **bold** ...\n}}}\n"),
+            # (u"#format creole\n... **bold** ...\n", "#format creole\n... **bold** ...\n"),
         ]
         for i in data:
             yield (self.do, ) + i
@@ -80,24 +80,24 @@
     def test_link(self):
         data = [
             (u'[[SomePage#subsection|subsection of Some Page]]', '[[SomePage#subsection|subsection of Some Page]]\n'),
-            (u'[[SomePage|{{attachment:samplegraphic.png}}|target=_blank]]', '[[SomePage|{{attachment:samplegraphic.png}}|target=_blank]]\n'),
-            (u'[[SomePage|{{attachment:samplegraphic.png}}|&target=_blank]]', '[[SomePage|{{attachment:samplegraphic.png}}|&target=_blank]]\n'),
+            # (u'[[SomePage|{{attachment:samplegraphic.png}}|target=_blank]]', '[[SomePage|{{attachment:samplegraphic.png}}|target=_blank]]\n'),
+            # (u'[[SomePage|{{attachment:samplegraphic.png}}|&target=_blank]]', '[[SomePage|{{attachment:samplegraphic.png}}|&target=_blank]]\n'),
             (u'[[../SisterPage|link text]]', '[[../SisterPage|link text]]\n'),
-            (u'[[http://static.moinmo.in/logos/moinmoin.png|{{attachment:samplegraphic.png}}|target=_blank]]', '[[http://static.moinmo.in/logos/moinmoin.png|{{attachment:samplegraphic.png}}|target=_blank]]\n'),
-            (u'[[http://moinmo.in/|MoinMoin Wiki|class=green dotted, accesskey=1]]', '[[http://moinmo.in/|MoinMoin Wiki|class=green dotted,accesskey=1]]\n'),
-            (u'[[MoinMoin:MoinMoinWiki|MoinMoin Wiki|&action=diff,&rev1=1,&rev2=2]]', '[[MoinMoin:MoinMoinWiki|MoinMoin Wiki|&action=diff,&rev1=1,&rev2=2]]\n'),
-            (u'[[attachment:HelpOnImages/pineapple.jpg|a pineapple|&do=get]]', '[[attachment:HelpOnImages/pineapple.jpg|a pineapple|&do=get]]\n'),
-            (u'[[attachment:filename.txt]]', '[[attachment:filename.txt]]\n')
+            # (u'[[http://static.moinmo.in/logos/moinmoin.png|{{attachment:samplegraphic.png}}|target=_blank]]', '[[http://static.moinmo.in/logos/moinmoin.png|{{attachment:samplegraphic.png}}|target=_blank]]\n'),
+            # (u'[[http://moinmo.in/|MoinMoin Wiki|class=green dotted, accesskey=1]]', '[[http://moinmo.in/|MoinMoin Wiki|class=green dotted,accesskey=1]]\n'),
+            # (u'[[MoinMoin:MoinMoinWiki|MoinMoin Wiki|&action=diff,&rev1=1,&rev2=2]]', '[[MoinMoin:MoinMoinWiki|MoinMoin Wiki|&action=diff,&rev1=1,&rev2=2]]\n'),
+            # (u'[[attachment:HelpOnImages/pineapple.jpg|a pineapple|&do=get]]', '[[attachment:HelpOnImages/pineapple.jpg|a pineapple|&do=get]]\n'),
+            # (u'[[attachment:filename.txt]]', '[[attachment:filename.txt]]\n')
         ]
         for i in data:
             yield (self.do, ) + i
 
     def test_list(self):
         data = [
-            (u" * A\n * B\n  1. C\n  1. D\n   I. E\n   I. F\n", ' * A\n * B\n  1. C\n  1. D\n   I. E\n   I. F\n'),
+            # (u" * A\n * B\n  1. C\n  1. D\n   I. E\n   I. F\n", ' * A\n * B\n  1. C\n  1. D\n   I. E\n   I. F\n'),
             (u" i. E\n i. F\n", " i. E\n i. F\n"),
             (u" A:: B\n :: C\n :: D\n", ' A::\n :: B\n :: C\n :: D\n'),
-            (u" A::\n :: B\n :: C\n :: D\n", ' A::\n :: B\n :: C\n :: D\n'),
+            # (u" A::\n :: B\n :: C\n :: D\n", ' A::\n :: B\n :: C\n :: D\n'),
         ]
         for i in data:
             yield (self.do, ) + i
@@ -115,19 +115,20 @@
 
     def test_object(self):
         data = [
-            (u"{{drawing:anywikitest.adraw}}", '{{drawing:anywikitest.adraw}}\n'),
+            # (u"{{drawing:anywikitest.adraw}}", '{{drawing:anywikitest.adraw}}\n'),
             (u"{{http://static.moinmo.in/logos/moinmoin.png}}\n", '{{http://static.moinmo.in/logos/moinmoin.png}}\n'),
             (u'{{http://static.moinmo.in/logos/moinmoin.png|alt text}}', '{{http://static.moinmo.in/logos/moinmoin.png|alt text}}\n'),
-            (u'{{http://static.moinmo.in/logos/moinmoin.png|alt text|width=100 height=150 align=right}}', '{{http://static.moinmo.in/logos/moinmoin.png|alt text|width=100 height=150 align=right}}\n'),
-            (u'{{attachment:image.png}}', '{{attachment:image.png}}\n'),
-            (u'{{attachment:image.png|alt text}}', '{{attachment:image.png|alt text}}\n'),
-            (u'{{attachment:image.png|alt text|width=100 align=left height=150}}', '{{attachment:image.png|alt text|width=100 align=left height=150}}\n'),
+            # (u'{{http://static.moinmo.in/logos/moinmoin.png|alt text|width=100 height=150 align=right}}', '{{http://static.moinmo.in/logos/moinmoin.png|alt text|width=100 height=150 align=right}}\n'),
+            # (u'{{attachment:image.png}}', '{{attachment:image.png}}\n'),
+            # (u'{{attachment:image.png|alt text}}', '{{attachment:image.png|alt text}}\n'),
+            # (u'{{attachment:image.png|alt text|width=100 align=left height=150}}', '{{attachment:image.png|alt text|width=100 align=left height=150}}\n'),
 
         ]
         for i in data:
             yield (self.do, ) + i
 
     def test_page(self):
+        pytest.skip("please help fixing moin wiki round trip tests") # XXX TODO
         data = [
             (u"""
 This page aims to introduce the most important elements of MoinMoin``'s syntax at a glance, showing first the markup verbatim and then how it is rendered by the wiki engine. Additionally, you'll find links to the relative help pages. Please note that some of the features depend on your configuration.
--- a/MoinMoin/storage/backends/_tests/__init__.py	Sat Aug 25 17:07:45 2012 +0800
+++ b/MoinMoin/storage/backends/_tests/__init__.py	Sat Aug 25 17:09:09 2012 +0800
@@ -60,6 +60,7 @@
         m, d = self.be.retrieve(metaid)
         assert m == meta
         assert d.read() == data
+        d.close()
         self.be.remove(metaid)
         with pytest.raises(KeyError):
             self.be.retrieve(metaid)
--- a/MoinMoin/util/_tests/test_lock.py	Sat Aug 25 17:07:45 2012 +0800
+++ b/MoinMoin/util/_tests/test_lock.py	Sat Aug 25 17:09:09 2012 +0800
@@ -80,21 +80,23 @@
     def testIsExpired(self):
         """ util.lock: ExclusiveLock: isExpired """
         timeout = 2.0
+        extra = 0.1 # extra delay to avoid occasional failure on windows
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
             pytest.skip("can't acquire lock")
         assert not lock.isExpired()
-        time.sleep(timeout)
+        time.sleep(timeout + extra)
         assert lock.isExpired()
 
     def testExpire(self):
         """ util.lock: ExclusiveLock: expire """
         timeout = 2.0
+        extra = 0.1 # extra delay to avoid occasional failure on windows
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
             pytest.skip("can't acquire lock")
         assert not lock.expire()
-        time.sleep(timeout)
+        time.sleep(timeout + extra)
         assert lock.expire()
 
     def testExclusive(self):
--- a/MoinMoin/util/_tests/test_thread_monitor.py	Sat Aug 25 17:07:45 2012 +0800
+++ b/MoinMoin/util/_tests/test_thread_monitor.py	Sat Aug 25 17:09:09 2012 +0800
@@ -41,5 +41,5 @@
             result = Monitor_test_obj.trigger_dump(f)
         # read the content of first line
         with open(self.src, "r") as f:
-            f.seek(1)
+            f.readline()
             assert 'Dumping thread' in f.readline()