Skip to content

Commit 8f8b71a

Browse files
committedApr 12, 2012
ENH: @network decorator for tests
1 parent 9d09493 commit 8f8b71a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎pandas/util/testing.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,40 @@ def skip_if_no_package(*args, **kwargs):
294294
package_check(exc_failed_import=SkipTest,
295295
exc_failed_check=SkipTest,
296296
*args, **kwargs)
297+
298+
#
299+
# Additional tags decorators for nose
300+
#
301+
def network(t):
302+
"""
303+
Label a test as requiring network connection.
304+
305+
In some cases it is not possible to assume network presence (e.g. Debian
306+
build hosts).
307+
308+
Parameters
309+
----------
310+
t : callable
311+
The test requiring network connectivity.
312+
313+
Returns
314+
-------
315+
t : callable
316+
The decorated test `t`.
317+
318+
Examples
319+
--------
320+
A test can be decorated as requiring network like this::
321+
322+
from pandas.util.testing import *
323+
324+
@network
325+
def test_network(self):
326+
print 'Fetch the stars from http://'
327+
328+
And use ``nosetests -a '!network'`` to exclude running tests requiring
329+
network connectivity.
330+
"""
331+
332+
t.network = True
333+
return t

0 commit comments

Comments
 (0)
Please sign in to comment.