pediapress / mwlib

mediawiki parser library
103 stars 35 forks source link

test fails in tests/test_expander_time.py #51

Open keszybz opened 9 years ago

keszybz commented 9 years ago
$ py.test tests/
...
============================================ FAILURES =============================================
_________________________________________ test_codes[43] __________________________________________

s = 'xrU', expected = 'XVI', date = '1970-1-1 + 16 second'

    def e(s, expected, date="09 Feb 2008 10:55:17"):
>       expandstr(u'{{#time:%s|%s}}' % (s, date), expected)

tests/test_expander_time.py:8: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

s = '{{#time:xrU|1970-1-1 + 16 second}}', expected = 'XVI', wikidb = None, pagename = 'thispage'

    def expandstr(s, expected=None, wikidb=None, pagename='thispage'):
        """debug function. expand templates in string s"""
        if wikidb:
            db = wikidb
        else:
            db = DictDB(dict(a=s))

        te = evaluate.Expander(s, pagename=pagename, wikidb=db)
        res = te.expandTemplates()
        print "EXPAND: %r -> %r" % (s, res)
        if expected is not None:
>           assert res==expected, "expected %r, got %r" % (expected, res)
E           AssertionError: expected 'XVI', got u'<strong class="error">Error: invalid time</strong>'

/usr/lib64/python2.7/site-packages/mwlib/templ/misc.py:49: AssertionError
-------------------------------------- Captured stdout call ---------------------------------------
EXPAND: u'{{#time:xrU|1970-1-1 + 16 second}}' -> u'<strong class="error">Error: invalid time</strong>'
_____________________________________ test_time_minus_days[0] _____________________________________

s = '{{#time:Y-m-d| 20070827000000 -12 day}}', expected = '2007-08-15', wikidb = None
pagename = 'thispage'

    def expandstr(s, expected=None, wikidb=None, pagename='thispage'):
        """debug function. expand templates in string s"""
        if wikidb:
            db = wikidb
        else:
            db = DictDB(dict(a=s))

        te = evaluate.Expander(s, pagename=pagename, wikidb=db)
        res = te.expandTemplates()
        print "EXPAND: %r -> %r" % (s, res)
        if expected is not None:
>           assert res==expected, "expected %r, got %r" % (expected, res)
E           AssertionError: expected '2007-08-15', got u'<strong class="error">Error: invalid time</strong>'

/usr/lib64/python2.7/site-packages/mwlib/templ/misc.py:49: AssertionError
-------------------------------------- Captured stdout call ---------------------------------------
EXPAND: '{{#time:Y-m-d| 20070827000000 -12 day}}' -> u'<strong class="error">Error: invalid time</strong>'

This is with today's git (c41330f95e0e780026159ae95402b6d00511e05c), but those two tests fail also with mwlib 0.15.11 and 0.15.14.