Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get the cwd earlier so it's correct under nosetests.

  • Loading branch information...
commit 5506283972968ab8957f584af1a30ccd81578602 1 parent 830f109
@erikrose authored
Showing with 8 additions and 3 deletions.
  1. +6 −1 traceback/__init__.py
  2. +2 −2 traceback/tests.py
View
7 traceback/__init__.py
@@ -41,6 +41,11 @@ def _copy_to_globals(namespace, attrs):
_copy_to_globals(traceback, traceback.__all__)
+# Do this early so it's actually right. nosetests, for one, changes directory
+# early in the test-running process.
+_cwd = getcwd()
+
+
# Overrides of various traceback-module functions:
def format_list(extracted_list):
@@ -97,7 +102,7 @@ def simple_format_traceback(extracted_tb, stream=None):
return format_traceback(
extracted_tb,
cwd='' if environ.get('TRACEFRONT_ABSOLUTE_PATHS', '').lower() in
- ('1', 'true', 'yes', 'on') else getcwd(),
+ ('1', 'true', 'yes', 'on') else _cwd,
term=Terminal(stream=stream), # () makes blessings not style. Hacky.
function_color=environ.get('TRACEFRONT_FUNCTION_COLOR', 12),
dim_color=environ.get('TRACEFRONT_DIM_COLOR', 8),
View
4 traceback/tests.py
@@ -126,13 +126,13 @@ def test_unicode():
def test_format_list():
- eq_(format_list(extract_tb(_tb())), [u' \x1b[90m\x1b[1mbbedit +21 tests.py\x1b(B\x1b[m\x1b[94m # _triple\x1b(B\x1b[m\n one()\n', u' \x1b[90m\x1b[1mbbedit +11 tests.py\x1b(B\x1b[m\x1b[94m # one\x1b(B\x1b[m\n two()\n', u' \x1b[90m\x1b[1mbbedit +10 tests.py\x1b(B\x1b[m\x1b[94m # two\x1b(B\x1b[m\n h[1]\n'])
+ eq_(format_list(extract_tb(_tb())), [u' \x1b[90m\x1b[1mbbedit +21 traceback/tests.py\x1b(B\x1b[m\x1b[94m # _triple\x1b(B\x1b[m\n one()\n', u' \x1b[90m\x1b[1mbbedit +11 traceback/tests.py\x1b(B\x1b[m\x1b[94m # one\x1b(B\x1b[m\n two()\n', u' \x1b[90m\x1b[1mbbedit +10 traceback/tests.py\x1b(B\x1b[m\x1b[94m # two\x1b(B\x1b[m\n h[1]\n'])
def test_print_tb():
out = StringIO()
print_tb(_tb(), file=out)
- eq_(out.getvalue(), u' bbedit +21 tests.py # _triple\n one()\n bbedit +11 tests.py # one\n two()\n bbedit +10 tests.py # two\n h[1]\n')
+ eq_(out.getvalue(), u' bbedit +21 traceback/tests.py # _triple\n one()\n bbedit +11 traceback/tests.py # one\n two()\n bbedit +10 traceback/tests.py # two\n h[1]\n')
def test_rebinding():
Please sign in to comment.
Something went wrong with that request. Please try again.