Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64481225
test_convert_wordPositions.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 27, 04:50
Size
2 KB
Mime Type
text/x-python
Expires
Wed, May 29, 04:50 (2 d)
Engine
blob
Format
Raw Data
Handle
17910772
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_convert_wordPositions.py
View Options
import
unittest
from
os
import
sep
,
path
,
remove
import
lxml.etree
as
ET
import
lxml.html
import
convert_wordPositions
from
convert_wordPositions
import
Converter
,
SVGConverter
,
HTMLConverter
from
datatypes.page
import
Page
class
TestConverter
(
unittest
.
TestCase
):
def
setUp
(
self
):
DATADIR
=
path
.
dirname
(
__file__
)
+
sep
+
'test_data'
self
.
test_file
=
DATADIR
+
sep
+
'test.xml'
self
.
test_svg_file
=
DATADIR
+
sep
+
'test421.svg'
self
.
outputfile_txt
=
'test.txt'
self
.
outputfile_html
=
'test.html'
self
.
outputfile_svg
=
'test.svg'
def
test_main
(
self
):
argv
=
[
'-t'
,
'-s'
,
self
.
test_svg_file
,
self
.
test_file
]
self
.
assertEqual
(
convert_wordPositions
.
main
(
argv
),
0
)
argv
=
[
'-t'
,
'-s'
,
self
.
test_svg_file
,
'-o'
,
self
.
outputfile_txt
,
self
.
test_file
]
self
.
assertEqual
(
convert_wordPositions
.
main
(
argv
),
0
)
self
.
assertEqual
(
path
.
isfile
(
self
.
outputfile_txt
),
True
)
argv
=
[
'-t'
,
'-s'
,
self
.
test_svg_file
,
'-o'
,
self
.
outputfile_html
,
self
.
test_file
]
self
.
assertEqual
(
convert_wordPositions
.
main
(
argv
),
0
)
self
.
assertEqual
(
path
.
isfile
(
self
.
outputfile_html
),
True
)
html_tree
=
lxml
.
html
.
parse
(
self
.
outputfile_html
)
self
.
assertEqual
(
html_tree
.
getroot
()
.
tag
,
'html'
)
argv
=
[
'-t'
,
'-s'
,
self
.
test_svg_file
,
'-o'
,
self
.
outputfile_svg
,
self
.
test_file
]
self
.
assertEqual
(
convert_wordPositions
.
main
(
argv
),
0
)
self
.
assertEqual
(
path
.
isfile
(
self
.
outputfile_svg
),
True
)
svg_tree
=
ET
.
parse
(
self
.
outputfile_svg
)
self
.
assertEqual
(
svg_tree
.
getroot
()
.
tag
,
'{http://www.w3.org/2000/svg}svg'
)
def
test_create_converter
(
self
):
page
=
Page
(
xml_source_file
=
self
.
test_file
,
svg_file
=
self
.
test_svg_file
)
converter
=
Converter
.
CREATE_CONVERTER
(
page
,
False
,
'SVG'
)
self
.
assertEqual
(
isinstance
(
converter
,
SVGConverter
),
True
)
converter
=
Converter
.
CREATE_CONVERTER
(
page
,
False
,
'HTML'
)
self
.
assertEqual
(
isinstance
(
converter
,
HTMLConverter
),
True
)
converter
=
Converter
.
CREATE_CONVERTER
(
page
,
False
)
self
.
assertEqual
(
isinstance
(
converter
,
Converter
),
True
)
def
tearDown
(
self
):
bool
(
path
.
isfile
(
self
.
outputfile_txt
))
and
remove
(
self
.
outputfile_txt
)
bool
(
path
.
isfile
(
self
.
outputfile_html
))
and
remove
(
self
.
outputfile_html
)
bool
(
path
.
isfile
(
self
.
outputfile_svg
))
and
remove
(
self
.
outputfile_svg
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment