##// END OF EJS Templates
[utils][tests][openpy] Remove nose
Samuel Gaist -
Show More
@@ -1,6 +1,5 b''
1 import io
1 import io
2 import os.path
2 import os.path
3 import nose.tools as nt
4
3
5 from IPython.utils import openpy
4 from IPython.utils import openpy
6
5
@@ -11,14 +10,14 b' nonascii_path = os.path.join(mydir, "../../core/tests/nonascii.py")'
11 def test_detect_encoding():
10 def test_detect_encoding():
12 with open(nonascii_path, "rb") as f:
11 with open(nonascii_path, "rb") as f:
13 enc, lines = openpy.detect_encoding(f.readline)
12 enc, lines = openpy.detect_encoding(f.readline)
14 nt.assert_equal(enc, "iso-8859-5")
13 assert enc == "iso-8859-5"
15
14
16
15
17 def test_read_file():
16 def test_read_file():
18 with io.open(nonascii_path, encoding="iso-8859-5") as f:
17 with io.open(nonascii_path, encoding="iso-8859-5") as f:
19 read_specified_enc = f.read()
18 read_specified_enc = f.read()
20 read_detected_enc = openpy.read_py_file(nonascii_path, skip_encoding_cookie=False)
19 read_detected_enc = openpy.read_py_file(nonascii_path, skip_encoding_cookie=False)
21 nt.assert_equal(read_detected_enc, read_specified_enc)
20 assert read_detected_enc == read_specified_enc
22 assert "coding: iso-8859-5" in read_detected_enc
21 assert "coding: iso-8859-5" in read_detected_enc
23
22
24 read_strip_enc_cookie = openpy.read_py_file(
23 read_strip_enc_cookie = openpy.read_py_file(
@@ -30,10 +29,10 b' def test_read_file():'
30 def test_source_to_unicode():
29 def test_source_to_unicode():
31 with io.open(nonascii_path, "rb") as f:
30 with io.open(nonascii_path, "rb") as f:
32 source_bytes = f.read()
31 source_bytes = f.read()
33 nt.assert_equal(
32 assert (
34 openpy.source_to_unicode(source_bytes, skip_encoding_cookie=False).splitlines(),
33 openpy.source_to_unicode(source_bytes, skip_encoding_cookie=False).splitlines()
35 source_bytes.decode("iso-8859-5").splitlines(),
34 == source_bytes.decode("iso-8859-5").splitlines()
36 )
35 )
37
36
38 source_no_cookie = openpy.source_to_unicode(source_bytes, skip_encoding_cookie=True)
37 source_no_cookie = openpy.source_to_unicode(source_bytes, skip_encoding_cookie=True)
39 nt.assert_not_in("coding: iso-8859-5", source_no_cookie)
38 assert "coding: iso-8859-5" not in source_no_cookie
General Comments 0
You need to be logged in to leave comments. Login now