Skip to content

Instantly share code, notes, and snippets.

@agronholm
Created March 12, 2014 10:30
Show Gist options
  • Save agronholm/9504388 to your computer and use it in GitHub Desktop.
Save agronholm/9504388 to your computer and use it in GitHub Desktop.
@pytest.fixture
def scheduler(request):
sched = DummyScheduler()
if 'start_scheduler' in request.keywords:
sched.start()
request.addfinalizer(lambda: sched.shutdown() if sched.running else None)
return sched
@pytest.fixture
def logstream(request, scheduler):
stream = BytesIO()
loghandler = StreamHandler(stream)
loghandler.setLevel(ERROR)
scheduler.logger.addHandler(loghandler)
request.addfinalizer(lambda: scheduler.logger.removeHandler(loghandler))
return stream
class TestOfflineScheduler(object):
def test_jobstore_twice(self, scheduler):
with pytest.raises(KeyError):
scheduler.add_jobstore(MemoryJobStore(), 'dummy')
scheduler.add_jobstore(MemoryJobStore(), 'dummy')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment