This involved many changes, some side effects of the change include: - remove of all `u"abc"` forms, in favor of `from __future__ import unicode_literals`. Their usage was inconsistent anyway, leading to problems when mixing with unicode content. - improve the tests, to allow printing for usecase even when crashing. Should make future test easier. This is done with a rather hacky `StdIO` class in `p3`, but it works. - for some reason, the skipped test for Python 2 seems to work now. While the previous point might seem related, it is not clear that this is actually the case.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from __future__ import unicode_literals
|
|
|
|
import unittest
|
|
import os
|
|
|
|
import dotdot
|
|
import fake_env
|
|
|
|
from pubs import endecoder, pretty, color, config
|
|
|
|
from str_fixtures import bibtex_raw0
|
|
|
|
|
|
class TestPretty(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
conf = config.load_default_conf()
|
|
color.setup(conf)
|
|
|
|
def test_oneliner(self):
|
|
decoder = endecoder.EnDecoder()
|
|
bibdata = decoder.decode_bibdata(bibtex_raw0)
|
|
line = 'Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web." (1999)'
|
|
self.assertEqual(color.undye(pretty.bib_oneliner(bibdata['Page99'])), line)
|
|
|
|
def test_oneliner_no_year(self):
|
|
decoder = endecoder.EnDecoder()
|
|
bibdata = decoder.decode_bibdata(bibtex_raw0)
|
|
bibdata['Page99'].pop('year')
|
|
line = 'Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web."'
|
|
self.assertEqual(color.undye(pretty.bib_oneliner(bibdata['Page99'])), line)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|