Skip to content

Instantly share code, notes, and snippets.

@wesm
Created August 5, 2013 22:34
Show Gist options
  • Select an option

  • Save wesm/6160217 to your computer and use it in GitHub Desktop.

Select an option

Save wesm/6160217 to your computer and use it in GitHub Desktop.
A metaclass for marking test cases (including superclasses) as requiring network connection (for nosetests -A "not network" to work)
# Author: Wes McKinney
# License: MIT
from pandas.util.testing import network
class NetworkTests(type):
def __new__(cls, name, bases, attrs):
for k, v in attrs.iteritems():
if k.startswith('test_'):
attrs[k] = network(v)
for base in bases:
for k, v in base.__dict__.iteritems():
if k.startswith('test_'):
attrs[k] = network(v)
return type.__new__(cls, name, bases, attrs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment