-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_xml2bib.py
44 lines (34 loc) · 1.05 KB
/
test_xml2bib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
from __future__ import print_function
import xml2bib
import unittest
class TestBibTeXWrite(unittest.TestCase):
verbose = False
def test_empty(self):
w = xml2bib.BibTeXWriter('', dict())
x = str(w)
self.assertTrue(len(x) > 0)
def test_basic(self):
d = {'creator': 'A. Einstein',
'year': 1905,
'title': 'The photo-electric effect',
'journal': 'Phys. Rev.'}
w = xml2bib.BibTeXWriter('AE05', d)
x = str(w)
self.assertTrue(len(x) > 0)
if (self.verbose):
print('testBasic:', x)
class TestXMLReader(unittest.TestCase):
def test_one(self):
f = 'xmlfiles/_10.14470_6t569239.xml'
x = xml2bib.XMLReader(f)
d = xml2bib.xml2dict(x)
c_names = ('Th, H.',
'Ba, N.',
'Ma, V.',
'Ri, J.',
'Ti, F.',)
c = ' and '.join(c_names)
self.assertEqual(d['author'], c)
if __name__ == '__main__':
unittest.main()