Created
March 12, 2014 10:30
-
-
Save agronholm/9504388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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