commit
0eccef32bf
2 changed files with 54 additions and 1 deletions
21
setup.py
21
setup.py
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
from setuptools.command.test import test as TestCommand
|
||||||
|
|
||||||
# Utility function to read the README file.
|
# Utility function to read the README file.
|
||||||
# Used for the long_description. It's nice, because now
|
# Used for the long_description. It's nice, because now
|
||||||
|
|
@ -9,6 +11,17 @@ from setuptools import setup
|
||||||
def read(fname):
|
def read(fname):
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
|
|
||||||
|
class PyTest(TestCommand):
|
||||||
|
def finalize_options(self):
|
||||||
|
TestCommand.finalize_options(self)
|
||||||
|
self.test_args = []
|
||||||
|
self.test_suite = True
|
||||||
|
|
||||||
|
def run_tests(self):
|
||||||
|
import pytest
|
||||||
|
errno = pytest.main(self.test_args)
|
||||||
|
sys.exit(errno)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='secretary',
|
name='secretary',
|
||||||
version='0.0.1',
|
version='0.0.1',
|
||||||
|
|
@ -24,6 +37,9 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Jinja2',
|
'Jinja2',
|
||||||
],
|
],
|
||||||
|
tests_require=['pytest'],
|
||||||
|
cmdclass={'test': PyTest},
|
||||||
|
test_suite='test_secretary',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
'Intended Audience :: End Users/Desktop',
|
'Intended Audience :: End Users/Desktop',
|
||||||
|
|
@ -33,5 +49,8 @@ setup(
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
]
|
],
|
||||||
|
extras_require={
|
||||||
|
'testing': ['pytest']
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
34
test_secretary.py
Normal file
34
test_secretary.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
from xml.dom.minidom import getDOMImplementation
|
||||||
|
from unittest import TestCase
|
||||||
|
from secretary import UndefinedSilently, pad_string, Render
|
||||||
|
|
||||||
|
def test_undefined_silently():
|
||||||
|
undefined = UndefinedSilently()
|
||||||
|
|
||||||
|
assert isinstance(undefined(), UndefinedSilently)
|
||||||
|
assert isinstance(undefined.attribute, UndefinedSilently)
|
||||||
|
assert unicode(undefined) == u''
|
||||||
|
assert str(undefined) == ''
|
||||||
|
|
||||||
|
def test_pad_string():
|
||||||
|
assert pad_string('TEST') == '0TEST'
|
||||||
|
assert pad_string('TEST', 4) == 'TEST'
|
||||||
|
assert pad_string(1) == '00001'
|
||||||
|
|
||||||
|
class RenderTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
root = os.path.dirname(__file__)
|
||||||
|
impl = getDOMImplementation()
|
||||||
|
template = os.path.join(root, 'simple_template.odt')
|
||||||
|
|
||||||
|
self.document = impl.createDocument(None, "some_tag", None)
|
||||||
|
self.render = Render(template)
|
||||||
|
|
||||||
|
def test_create_test_node(self):
|
||||||
|
assert self.render.create_text_node(self.document, 'text').toxml() == 'text'
|
||||||
|
|
||||||
|
def test_create_text_span_node(self):
|
||||||
|
assert self.render.create_text_span_node(self.document, 'text').toxml() == '<text:span>text</text:span>'
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue