Skip to content

Commit 117a746

Browse files
committed
add tox file. fix some tests
1 parent 382266a commit 117a746

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

conf_publisher/confluence.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ def is_equal(cls, first, second):
206206

207207
# 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
208208
# 'xsi:schemaLocation="http://www.atlassian.com/schema/confluence/4/ac/ confluence.xsd" '
209-
wrapper = '<?xml version="1.0" encoding="UTF-8"?>' \
210-
'<!DOCTYPE ac:confluence SYSTEM "confluence.dtd">' \
211-
'<ac:confluence xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/" ' \
212-
'xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/">{}</ac:confluence>'
209+
wrapper = u'<?xml version="1.0" encoding="UTF-8"?>' \
210+
u'<!DOCTYPE ac:confluence SYSTEM "confluence.dtd">' \
211+
u'<ac:confluence xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/" ' \
212+
u'xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/">{}</ac:confluence>'
213213

214-
first_xml = etree.XML(wrapper.format(first.encode(encoding='utf-8')), parser=cls._parser())
215-
second_xml = etree.XML(wrapper.format(second.encode(encoding='utf-8')), parser=cls._parser())
214+
first_xml = etree.XML(wrapper.format(first).encode(encoding='utf-8'), parser=cls._parser())
215+
second_xml = etree.XML(wrapper.format(second).encode(encoding='utf-8'), parser=cls._parser())
216216
return cls._elements_equal(first_xml, second_xml)
217217

218218
@staticmethod
@@ -225,7 +225,6 @@ def _parser():
225225
# fix unknown entity
226226
# http://stackoverflow.com/questions/7237466/python-elementtree-support-for-parsing-unknown-xml-entities
227227
parser = etree.XMLParser()
228-
parser.parser.UseForeignDTD(True)
229228
parser.entity['nbsp'] = 'nbsp'
230229
return parser
231230

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
'License :: OSI Approved :: MIT License',
2121
'Operating System :: OS Independent',
2222
'Programming Language :: Python :: 2.7',
23+
'Programming Language :: Python :: 3.3',
2324
'Programming Language :: Python :: 3.4',
25+
'Programming Language :: Python :: 3.5',
2426
'Topic :: Software Development :: Documentation',
2527
],
2628
entry_points={

tests/data_providers/test_sphinx_fjson_data_provider.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@ class SphinxFJsonDataProviderTestCase(TestCase):
99
tests_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1010

1111
def test_get_source_1(self):
12-
result = SphinxFJsonDataProvider().get_source('file')
12+
result = SphinxFJsonDataProvider(root_dir=self.tests_root).get_source('file')
1313
expected = os.path.join(self.tests_root, 'docs/build/json/file.fjson')
14-
1514
self.assertEqual(expected, result)
1615

1716
def test_get_source_2(self):
18-
result = SphinxFJsonDataProvider(root_dir='./', base_dir='result').get_source('file')
17+
result = SphinxFJsonDataProvider(root_dir=self.tests_root, base_dir='result').get_source('file')
1918
expected = os.path.join(self.tests_root, 'result/file.fjson')
20-
2119
self.assertEqual(expected, result)
2220

2321
def test_get_image(self):
24-
result = SphinxFJsonDataProvider(base_dir='fixtures').get_image('test_image.png')
22+
result = SphinxFJsonDataProvider(root_dir=self.tests_root, base_dir='fixtures').get_image('test_image.png')
2523
expected = os.path.join(self.tests_root, 'fixtures/_images/test_image.png')
2624
self.assertEqual(expected, result)
2725

2826
def test_get_attachment(self):
29-
result = SphinxFJsonDataProvider(base_dir='fixtures').get_attachment('test_download.txt')
27+
result = SphinxFJsonDataProvider(root_dir=self.tests_root, base_dir='fixtures').get_attachment('test_download.txt')
3028
expected = os.path.join(self.tests_root, 'fixtures/_downloads/test_download.txt')
3129
self.assertEqual(expected, result)

tests/test_publish.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from unittest import TestCase
22
import random
3+
import os
34

45
from conf_publisher.confluence import Page
56
from conf_publisher.publish import Publisher
@@ -57,7 +58,8 @@ def test_attachment_publish(self):
5758
page.title = 'Title'
5859
page.body = 'Body'
5960

60-
data_provider = SphinxFJsonDataProvider(base_dir=config.base_dir)
61+
tests_root = os.path.dirname(os.path.abspath(__file__))
62+
data_provider = SphinxFJsonDataProvider(root_dir=tests_root, base_dir=config.base_dir)
6163
page_manager = FakePagePublisher([page])
6264
attachment_manager = FakeAttachmentPublisher()
6365
publisher = Publisher(config, data_provider, page_manager, attachment_manager)

tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tox]
2+
envlist =
3+
{py27,py33,py34,py35}
4+
{py27,py33,py34,py35}-lxml
5+
6+
[testenv]
7+
commands = nosetests ./tests/ {posargs}
8+
deps =
9+
lxml: lxml
10+
nose
11+
coverage

0 commit comments

Comments
 (0)