예제 #1
0
def test_unicode():
    """Don't have encoding explosions when a line of code contains non-ASCII."""
    raise SkipTest
    unicode_tb = ([
         ("/usr/lib/whatever.py", 69, 'getMethod', """return u'あ'""")
        ], AttributeError, AttributeError("'NoneType' object has no pants.'"))
    ''.join(format_traceback(*unicode_tb))
예제 #2
0
def test_syntax_error():
    """Special handling of syntax errors should format nicely and not crash."""
    raise SkipTest
    options = dict(term=Terminal(stream=StringIO()))
    f = ''.join(format_traceback(*syntax_error_tb, **options))
    assert f.endswith(
        """vi +97  /Users/erose/Checkouts/nose-progress/noseprogressive/tests/test_integration.py
    :bad
    ^
SyntaxError: invalid syntax
""")
예제 #3
0
def test_empty_tracebacks():
    """Make sure we don't crash on empty tracebacks.

    Sometimes, stuff crashes before we even get to the test. pdbpp has been
    doing this a lot to me lately. When that happens, we receive an empty
    traceback.

    """
    list(format_traceback(
        [],
        AttributeError,
        AttributeError("'NoneType' object has no attribute 'pgpImportPubkey'")))
예제 #4
0
def test_non_syntax_error():
    """Typical error formatting should work and relativize paths."""
    raise SkipTest
    options = dict(term=Terminal(stream=StringIO()))
    f = ''.join(format_traceback(*attr_error_tb, **options))
    print f
    print repr(f)
    eq_(f, """  vi +2926 /usr/share/PackageKit/helpers/yum/yumBackend.py  # install_signature
    self.yumbase.getKeyForPackage(pkg, askcb = lambda x, y, z: True)
  vi +4309 /usr/lib/python2.6/site-packages/yum/__init__.py  # getKeyForPackage
    result = ts.pgpImportPubkey(misc.procgpgkey(info['raw_key']))
  vi +59   /usr/lib/python2.6/site-packages/rpmUtils/transaction.py  # __getattr__
    return self.getMethod(attr)
  vi +69   {this_file}  # getMethod
    return getattr(self.ts, method)
AttributeError: 'NoneType' object has no attribute 'pgpImportPubkey'
""".format(this_file=source_path(__file__)))