16
16
from pathlib import Path
17
17
18
18
import pypandoc
19
- from pypandoc .py3compat import path2url , string_types , unicode_type
19
+ from pypandoc .py3compat import path2url
20
20
21
21
22
22
@contextlib .contextmanager
@@ -53,7 +53,7 @@ def closed_tempfile(suffix, text=None, dir_name=None, prefix=None):
53
53
# Stolen from pandas
54
54
def is_list_like (arg ):
55
55
return (hasattr (arg , '__iter__' ) and
56
- not isinstance (arg , string_types ))
56
+ not isinstance (arg , str ))
57
57
58
58
59
59
@contextlib .contextmanager
@@ -129,10 +129,6 @@ def assert_produces_warning(expected_warning=Warning, filter_level="always",
129
129
130
130
class TestPypandoc (unittest .TestCase ):
131
131
132
- # Python 2 compatibility
133
- if not hasattr (unittest .TestCase , 'assertRaisesRegex' ):
134
- assertRaisesRegex = unittest .TestCase .assertRaisesRegexp
135
-
136
132
def setUp (self ):
137
133
if 'HOME' not in os .environ :
138
134
# if this is used with older versions of pandoc-citeproc
@@ -155,7 +151,7 @@ def test_get_pandoc_formats(self):
155
151
def test_get_pandoc_version (self ):
156
152
assert "HOME" in os .environ , "No HOME set, this will error..."
157
153
version = pypandoc .get_pandoc_version ()
158
- self .assertTrue (isinstance (version , pypandoc . string_types ))
154
+ self .assertTrue (isinstance (version , str ))
159
155
major = int (version .split ("." )[0 ])
160
156
self .assertTrue (major in [0 , 1 , 2 , 3 ])
161
157
@@ -524,12 +520,12 @@ def test_unicode_input(self):
524
520
# make sure that pandoc always returns unicode and does not mishandle it
525
521
expected = u'üäöîôû{0}' .format (os .linesep )
526
522
written = pypandoc .convert_text (u'<p>üäöîôû</p>' , 'md' , format = 'html' )
527
- self .assertTrue (isinstance (written , unicode_type ))
523
+ self .assertTrue (isinstance (written , str ))
528
524
self .assertEqualExceptForNewlineEnd (expected , written )
529
525
bytes = u'<p>üäöîôû</p>' .encode ("utf-8" )
530
526
written = pypandoc .convert_text (bytes , 'md' , format = 'html' )
531
527
self .assertTrue (expected == written )
532
- self .assertTrue (isinstance (written , unicode_type ))
528
+ self .assertTrue (isinstance (written , str ))
533
529
534
530
# Only use german umlauts in the next test, as iso-8859-15 covers that
535
531
expected = u'äüäö{0}' .format (os .linesep )
@@ -550,7 +546,7 @@ def f():
550
546
# with the right encoding it should work...
551
547
written = pypandoc .convert_text (bytes , 'md' , format = 'html' , encoding = "iso-8859-15" )
552
548
self .assertEqualExceptForNewlineEnd (expected , written )
553
- self .assertTrue (isinstance (written , unicode_type ))
549
+ self .assertTrue (isinstance (written , str ))
554
550
555
551
def test_conversion_from_non_plain_text_file (self ):
556
552
with closed_tempfile ('.docx' ) as file_name :
0 commit comments