import unittest
from ..examples.sample_data import (temperature_ramp, multisource_event,
                                    image_and_scalar)
from metadatastore.api import Document

class CommonSampleDataTests(object):
    def setUp(self):
        pass

    def test_basic_usage(self):
        events = self.example.run()

        # check expected types
        self.assertTrue(isinstance(events, list))
        self.assertTrue(isinstance(events[0], Document))


class TestTemperatureRamp(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = temperature_ramp


class TestMultisourceEvent(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = multisource_event


class TestImageAndScalar(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = image_and_scalar

from nose.tools import assert_true
from ..examples.sample_data import (temperature_ramp, multisource_event,
                                    image_and_scalar)
from metadatastore.api import Document

def run_example(example):
    events = example.run()
    assert_true(isinstance(events, list))
    assert_true(isinstance(events[0], Document))

def test_examples():
    for example in [temperature_ramp, multisource_event, image_and_scalar]:
        yield run_example, example

Use generator test for examples.
REF: Use generator test for examples.

- import unittest
+ from nose.tools import assert_true
  from ..examples.sample_data import (temperature_ramp, multisource_event,
                                      image_and_scalar)
  from metadatastore.api import Document
  
- class CommonSampleDataTests(object):
-     def setUp(self):
-         pass
+ def run_example(example):
+     events = example.run()
+     assert_true(isinstance(events, list))
+     assert_true(isinstance(events[0], Document))
  
-     def test_basic_usage(self):
-         events = self.example.run()
+ def test_examples():
+     for example in [temperature_ramp, multisource_event, image_and_scalar]:
+         yield run_example, example
  
-         # check expected types
-         self.assertTrue(isinstance(events, list))
-         self.assertTrue(isinstance(events[0], Document))
- 
- 
- class TestTemperatureRamp(CommonSampleDataTests, unittest.TestCase):
- 
-     def setUp(self):
-         self.example = temperature_ramp
- 
- 
- class TestMultisourceEvent(CommonSampleDataTests, unittest.TestCase):
- 
-     def setUp(self):
-         self.example = multisource_event
- 
- 
- class TestImageAndScalar(CommonSampleDataTests, unittest.TestCase):
- 
-     def setUp(self):
-         self.example = image_and_scalar
- 
Use generator test for examples.
## Code Before:
import unittest
from ..examples.sample_data import (temperature_ramp, multisource_event,
                                    image_and_scalar)
from metadatastore.api import Document

class CommonSampleDataTests(object):
    def setUp(self):
        pass

    def test_basic_usage(self):
        events = self.example.run()

        # check expected types
        self.assertTrue(isinstance(events, list))
        self.assertTrue(isinstance(events[0], Document))


class TestTemperatureRamp(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = temperature_ramp


class TestMultisourceEvent(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = multisource_event


class TestImageAndScalar(CommonSampleDataTests, unittest.TestCase):

    def setUp(self):
        self.example = image_and_scalar

## Instruction:
Use generator test for examples.
## Code After:
from nose.tools import assert_true
from ..examples.sample_data import (temperature_ramp, multisource_event,
                                    image_and_scalar)
from metadatastore.api import Document

def run_example(example):
    events = example.run()
    assert_true(isinstance(events, list))
    assert_true(isinstance(events[0], Document))

def test_examples():
    for example in [temperature_ramp, multisource_event, image_and_scalar]:
        yield run_example, example
