Skip to content

Commit

Permalink
Merge branch 'hotfix/1.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalloc committed Mar 10, 2018
2 parents 39d0abc + d83c57b commit 00aa427
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changelog
=========

* :release:`1.5.1 <10-3-2018>`
* :bug:`767` Fixed traceback variable capture for cases where ``self=None``
* :release:`1.5.0 <7-3-2018>`
* :feature:`590` Add support for labeling parametrization variations
* :feature:`697` Added ``slash.before_interactive_shell`` hook
Expand Down
2 changes: 1 addition & 1 deletion slash/utils/traceback_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _unwrap_self_locals(local_pairs):
for name, value in local_pairs:
yield name, value
if name == 'self':
for attr_name, attr_value in value.__dict__.items():
for attr_name, attr_value in getattr(value, '__dict__', {}).items():
yield 'self.{}'.format(attr_name), attr_value


Expand Down
22 changes: 22 additions & 0 deletions tests/test_add_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,25 @@ def _search_variable(variable_name, variable_value):
assert found == log_variables, 'Variable {!r} not found in traceback log!'.format(variable_name)
_search_variable('x_variable', 'xxx')
_search_variable('self.property_value', 'yyy')


def test_add_error_log_traceback_variables_self_none(suite, suite_test, config_override, tmpdir):
config_override('log.core_log_level', logbook.TRACE)
config_override('log.traceback_variables', True)
config_override('log.root', str(tmpdir.join('logs')))

@suite_test.prepend_body
def __code__(): # pylint: disable=unused-variable
# to avoid the line itself from being detected
self = None # pylint: disable=unused-variable

suite_test.when_run.error()
res = suite.run()
result = res[suite_test]

with open(result.get_log_path()) as f:
lines = f.read()

assert 'self: None' in lines
[err] = result.get_errors()
assert 'Test exception' in str(err)

0 comments on commit 00aa427

Please sign in to comment.