1616import sys
1717
1818import nose .tools as nt
19+ import pytest
20+
21+ from IPython .testing .decorators import skip_iptest_but_not_pytest
1922
2023from IPython .utils import capture
2124
6669#-----------------------------------------------------------------------------
6770# Test Functions
6871#-----------------------------------------------------------------------------
69-
70- def test_rich_output_empty ():
72+ @pytest .mark .parametrize ("method_mime" , _mime_map .items ())
73+ @skip_iptest_but_not_pytest
74+ def test_rich_output_empty (method_mime ):
7175 """RichOutput with no args"""
7276 rich = capture .RichOutput ()
73- for method , mime in _mime_map . items ():
74- yield nt .assert_equal , getattr (rich , method )(), None
77+ method , mime = method_mime
78+ nt .assert_equal ( getattr (rich , method )(), None )
7579
7680def test_rich_output ():
7781 """test RichOutput basics"""
7882 data = basic_data
7983 metadata = basic_metadata
8084 rich = capture .RichOutput (data = data , metadata = metadata )
81- yield nt .assert_equal , rich ._repr_html_ (), data [' text/html' ]
82- yield nt .assert_equal , rich ._repr_png_ (), (data [' image/png' ], metadata [' image/png' ] )
83- yield nt .assert_equal , rich ._repr_latex_ (), None
84- yield nt .assert_equal , rich ._repr_javascript_ (), None
85- yield nt .assert_equal , rich ._repr_svg_ (), None
85+ nt .assert_equal ( rich ._repr_html_ (), data [" text/html" ])
86+ nt .assert_equal ( rich ._repr_png_ (), (data [" image/png" ], metadata [" image/png" ]) )
87+ nt .assert_equal ( rich ._repr_latex_ (), None )
88+ nt .assert_equal ( rich ._repr_javascript_ (), None )
89+ nt .assert_equal ( rich ._repr_svg_ (), None )
8690
87- def test_rich_output_no_metadata ():
91+
92+ @skip_iptest_but_not_pytest
93+ @pytest .mark .parametrize ("method_mime" , _mime_map .items ())
94+ def test_rich_output_no_metadata (method_mime ):
8895 """test RichOutput with no metadata"""
8996 data = full_data
9097 rich = capture .RichOutput (data = data )
91- for method , mime in _mime_map .items ():
92- yield nt .assert_equal , getattr (rich , method )(), data [mime ]
98+ method , mime = method_mime
99+ nt .assert_equal (getattr (rich , method )(), data [mime ])
100+
93101
94- def test_rich_output_metadata ():
102+ @skip_iptest_but_not_pytest
103+ @pytest .mark .parametrize ("method_mime" , _mime_map .items ())
104+ def test_rich_output_metadata (method_mime ):
95105 """test RichOutput with metadata"""
96106 data = full_data
97107 metadata = full_metadata
98108 rich = capture .RichOutput (data = data , metadata = metadata )
99- for method , mime in _mime_map . items ():
100- yield nt .assert_equal , getattr (rich , method )(), (data [mime ], metadata [mime ])
109+ method , mime = method_mime
110+ nt .assert_equal ( getattr (rich , method )(), (data [mime ], metadata [mime ]) )
101111
102112def test_rich_output_display ():
103113 """test RichOutput.display
@@ -109,10 +119,10 @@ def test_rich_output_display():
109119 rich = capture .RichOutput (data = data )
110120 with capture .capture_output () as cap :
111121 rich .display ()
112- yield nt .assert_equal , len (cap .outputs ), 1
122+ nt .assert_equal ( len (cap .outputs ), 1 )
113123 rich2 = cap .outputs [0 ]
114- yield nt .assert_equal , rich2 .data , rich .data
115- yield nt .assert_equal , rich2 .metadata , rich .metadata
124+ nt .assert_equal ( rich2 .data , rich .data )
125+ nt .assert_equal ( rich2 .metadata , rich .metadata )
116126
117127def test_capture_output ():
118128 """capture_output works"""
@@ -121,8 +131,9 @@ def test_capture_output():
121131 print (hello_stdout , end = "" )
122132 print (hello_stderr , end = "" , file = sys .stderr )
123133 rich .display ()
124- yield nt .assert_equal , hello_stdout , cap .stdout
125- yield nt .assert_equal , hello_stderr , cap .stderr
134+ nt .assert_equal (hello_stdout , cap .stdout )
135+ nt .assert_equal (hello_stderr , cap .stderr )
136+
126137
127138def test_capture_output_no_stdout ():
128139 """test capture_output(stdout=False)"""
@@ -131,9 +142,10 @@ def test_capture_output_no_stdout():
131142 print (hello_stdout , end = "" )
132143 print (hello_stderr , end = "" , file = sys .stderr )
133144 rich .display ()
134- yield nt .assert_equal , "" , cap .stdout
135- yield nt .assert_equal , hello_stderr , cap .stderr
136- yield nt .assert_equal , len (cap .outputs ), 1
145+ nt .assert_equal ("" , cap .stdout )
146+ nt .assert_equal (hello_stderr , cap .stderr )
147+ nt .assert_equal (len (cap .outputs ), 1 )
148+
137149
138150def test_capture_output_no_stderr ():
139151 """test capture_output(stderr=False)"""
@@ -143,9 +155,10 @@ def test_capture_output_no_stderr():
143155 print (hello_stdout , end = "" )
144156 print (hello_stderr , end = "" , file = sys .stderr )
145157 rich .display ()
146- yield nt .assert_equal , hello_stdout , cap .stdout
147- yield nt .assert_equal , "" , cap .stderr
148- yield nt .assert_equal , len (cap .outputs ), 1
158+ nt .assert_equal (hello_stdout , cap .stdout )
159+ nt .assert_equal ("" , cap .stderr )
160+ nt .assert_equal (len (cap .outputs ), 1 )
161+
149162
150163def test_capture_output_no_display ():
151164 """test capture_output(display=False)"""
@@ -154,6 +167,6 @@ def test_capture_output_no_display():
154167 print (hello_stdout , end = "" )
155168 print (hello_stderr , end = "" , file = sys .stderr )
156169 rich .display ()
157- yield nt .assert_equal , hello_stdout , cap .stdout
158- yield nt .assert_equal , hello_stderr , cap .stderr
159- yield nt .assert_equal , cap .outputs , []
170+ nt .assert_equal ( hello_stdout , cap .stdout )
171+ nt .assert_equal ( hello_stderr , cap .stderr )
172+ nt .assert_equal ( cap .outputs , [])
0 commit comments