Esempio n. 1
0
 def tearDown(self):
     """Tear down the test fixture
     """
     # Some tests may leave pl 'configured'
     plot._SETUP_DONE = False  # pylint: disable=protected-access
     log.reset_instance()
     conf.reset_instance()
Esempio n. 2
0
 def tearDown(self):
     """Tear down the test fixture
     """
     # Some tests may leave pl 'configured'
     plot._SETUP_DONE = False  # pylint: disable=protected-access
     log.reset_instance()
     conf.reset_instance()
Esempio n. 3
0
    def setUp(self):
        """Set up the test
        """
        self.log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(self.log_stream)

        log.reset_instance()
        conf.reset_instance()
    def setUp(self):
        """Set up the test
        """
        self.log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(self.log_stream)

        log.reset_instance()
        conf.reset_instance()
Esempio n. 5
0
 def test_setup_without_seaborn(self):
     """Test setup mentions missing seaborn
     """
     with mock.patch.dict('sys.modules', {'seaborn': None}):
         log_stream = StringIO()
         Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
         log.reset_instance()
         log.initialize()
         plot.setup_plotting()
         self.assertRegexpMatches(log_stream.getvalue(),
                                  r'Cannot import seaborn')
Esempio n. 6
0
 def test_setup_without_seaborn(self):
     """Test setup mentions missing seaborn
     """
     with mock.patch.dict('sys.modules', {'seaborn': None}):
         log_stream = StringIO()
         Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
         log.reset_instance()
         log.initialize()
         plot.setup_plotting()
         self.assertRegexpMatches(log_stream.getvalue(),
                                  r'Cannot import seaborn')
    def test_basic_functionality(self):
        """Test the basic function of the TargetCreator
        """
        log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
        log.reset_instance()
        log.initialize(console_level=logging.DEBUG)

        queue = multiprocessing.Queue()
        target_fun = TargetCreator(lambda: None, queue, 'bla')
        target_fun()

        # Should have logged running
        self.assertNotEqual(len(log_stream.getvalue()), 0)
        self.assertRegexpMatches(log_stream.getvalue(), r'Running bla')
        self.assertTrue(queue.get())
Esempio n. 8
0
    def test_basic_functionality(self):
        """Test the basic function of the TargetCreator
        """
        log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
        log.reset_instance()
        log.initialize(console_level=logging.DEBUG)

        queue = multiprocessing.Queue()
        target_fun = TargetCreator(lambda: None, queue, 'bla')
        target_fun()

        # Should have logged running
        self.assertNotEqual(len(log_stream.getvalue()), 0)
        self.assertRegexpMatches(log_stream.getvalue(), r'Running bla')
        self.assertTrue(queue.get())
    def test_raises_exception(self):
        """Test the TargetCreator with a function that raises an exception
        """
        def target():
            """Test function
            """
            raise RuntimeError("bla")

        log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
        log.reset_instance()
        log.initialize(console_level=logging.DEBUG)

        queue = multiprocessing.Queue()
        target_fun = TargetCreator(target, queue, 'bla')
        self.assertRaises(RuntimeError, target_fun)

        # Should have logged running
        self.assertNotEqual(len(log_stream.getvalue()), 0)
        self.assertRegexpMatches(log_stream.getvalue(), r'Running bla')
        self.assertRegexpMatches(log_stream.getvalue(),
                                 r'Error in sub-process')
        self.assertRegexpMatches(log_stream.getvalue(), r'RuntimeError: bla')
        self.assertTrue(queue.get())
Esempio n. 10
0
    def test_raises_exception(self):
        """Test the TargetCreator with a function that raises an exception
        """
        def target():
            """Test function
            """
            raise RuntimeError("bla")

        log_stream = io.StringIO()
        Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler(log_stream)
        log.reset_instance()
        log.initialize(console_level=logging.DEBUG)

        queue = multiprocessing.Queue()
        target_fun = TargetCreator(target, queue, 'bla')
        self.assertRaises(RuntimeError, target_fun)

        # Should have logged running
        self.assertNotEqual(len(log_stream.getvalue()), 0)
        self.assertRegexpMatches(log_stream.getvalue(), r'Running bla')
        self.assertRegexpMatches(log_stream.getvalue(),
                                 r'Error in sub-process')
        self.assertRegexpMatches(log_stream.getvalue(), r'RuntimeError: bla')
        self.assertTrue(queue.get())
Esempio n. 11
0
 def tearDown(self):
     """Clean up after the test
     """
     log.reset_instance()
Esempio n. 12
0
 def tearDown(self):
     """Teardown test fixture
     """
     Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler()
     log.close()
     log.reset_instance()
Esempio n. 13
0
 def tearDown(self):
     """Clean up after the test
     """
     log.reset_instance()
Esempio n. 14
0
 def tearDown(self):
     """Teardown test fixture
     """
     Logger.CONSOLE_STREAM_HANDLER = logging.StreamHandler()
     log.close()
     log.reset_instance()