Tests for using stderr prompts

This commit is contained in:
Manuel Ebert 2013-07-22 12:04:32 +02:00
parent d3edbfd53b
commit 279547c350
4 changed files with 17 additions and 4 deletions

View file

@ -1,9 +1,16 @@
from behave import *
import shutil
import os
from jrnl import jrnl
try:
from io import StringIO
except ImportError:
from cStringIO import StringIO
def before_scenario(context, scenario):
"""Before each scenario, backup all config and journal test data."""
context.messages = StringIO()
jrnl.util.STDERR = context.messages
for folder in ("configs", "journals"):
original = os.path.join("features", folder)
backup = os.path.join("features", folder+"_backup")
@ -14,6 +21,8 @@ def before_scenario(context, scenario):
def after_scenario(context, scenario):
"""After each scenario, restore all test data and remove backups."""
context.messages.close()
context.messages = None
for folder in ("configs", "journals"):
original = os.path.join("features", folder)
backup = os.path.join("features", folder+"_backup")