Пример #1
0
    def __init__(self, **kwargs):

        manager = kwargs.get('manager', None)
        if manager is None:
            manager = get_manager(stream=kwargs.get('stream', sys.stdout),
                                  counter_class=self.__class__,
                                  set_scroll=False)
            manager.counters[self] = 1
            kwargs['manager'] = manager

        super(Counter, self).__init__(**kwargs)
Пример #2
0
    def test_get_manager_notty(self):

        # stdout is not attached to a tty
        with redirect_output('stdout', OUTPUT):
            self.assertFalse(sys.stdout.isatty())
            manager = _manager.get_manager(unit='knights')
            self.assertIsInstance(manager, _manager.Manager)
            self.assertTrue('unit' in manager.defaults)
            self.assertFalse(manager.enabled)
            self.assertTrue('enabled' in manager.defaults)
            self.assertFalse(manager.defaults['enabled'])