From 831b065c89bd3624f6b6e5b119e0c35367e3c61e Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Wed, 24 Jun 2015 15:23:15 +0200 Subject: [PATCH] And tests too --- pygal/__init__.py | 6 +++--- pygal/test/test_maps.py | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 pygal/test/test_maps.py diff --git a/pygal/__init__.py b/pygal/__init__.py index 6e3188c..86f0977 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -60,13 +60,13 @@ CHARTS_BY_NAME = dict( from pygal.graph.map import BaseMap for entry in pkg_resources.iter_entry_points('pygal.maps'): try: - cls = entry.load() + module = entry.load() except Exception: warnings.warn('Unable to load %s pygal plugin \n\n%s' % ( entry, traceback.format_exc()), Warning) continue - setattr(maps, entry.name, cls) - for k, v in cls.__dict__.items(): + setattr(maps, entry.name, module) + for k, v in module.__dict__.items(): if isinstance(v, type) and issubclass(v, BaseMap) and v != BaseMap: CHARTS_BY_NAME[entry.name.capitalize() + k + 'Map'] = v diff --git a/pygal/test/test_maps.py b/pygal/test/test_maps.py new file mode 100644 index 0000000..d211630 --- /dev/null +++ b/pygal/test/test_maps.py @@ -0,0 +1,9 @@ +import pkg_resources + + +# Load plugins tests +for entry in pkg_resources.iter_entry_points('pygal.test.test_maps'): + module = entry.load() + for k, v in module.__dict__.items(): + if k.startswith('test_'): + globals()['test_maps_' + entry.name + '_' + k[5:]] = v