コード例 #1
0
from nose.tools import *
from nucleon.tests import get_test_app

app = get_test_app(__file__)

# Write your Nose tests below


def test_version():
    resp = app.get('/')
    eq_(resp.json, {'version': '0.0.1'})
コード例 #2
0
# coding: utf8
import sys
import re
import urllib
from nose.tools import eq_
from cStringIO import StringIO
from contextlib import contextmanager

from nucleon import tests
app = tests.get_test_app(__file__)


@contextmanager
def stderr(stream):
    """Context manager that replaces stderr while in a block."""
    stderr = sys.stderr
    sys.stderr = stream
    try:
        yield
    finally:
        stream.flush()
        sys.stderr = stderr


def test_failure():
    """Test that a failing call returns 500 and logs to stderr"""
    buf = StringIO()
    with stderr(buf):
        app.get('/', status=500)
    error_output = buf.getvalue()
    assert 'Traceback' in error_output, "Error output was %r" % error_output