# Buggy code
def __enter__(self):
    plugin_manager.hook.start_step(uuid=self.uuid, title=self.title, params=self.params)


# Traceback (PyTestError)
$ pytest test_3.py --alluredir areport4
========================================================================= test session starts ==========================================================================
platform linux2 -- Python 2.7.8, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
metadata: {'Python': '2.7.8', 'Platform': 'Linux-4.4.0-85-generic-x86_64-with-Ubuntu-14.04-trusty', 'Packages': {'py': '1.4.34', 'pytest': '3.1.3', 'pluggy': '0.4.0'}, 'JAVA_HOME': '/usr/lib/jvm/java-8-oracle', 'Plugins': {'xdist': '1.18.1', 'allure-pytest': '2.1.0b1', 'html': '1.14.2', 'PyTestTelegramReport': '0.0.7', 'instafail': '0.3.0', 'metadata': '1.5.0'}}
rootdir: /home/asdef/Dropbox/Work/Git/PyTestError, inifile:
plugins: xdist-1.18.1, metadata-1.5.0, instafail-0.3.0, html-1.14.2, allure-pytest-2.1.0b1, PyTestTelegramReport-0.0.7
collected 1 item s

test_3.py .

======================================================================= 1 passed in 0.70 seconds =======================================================================
(autotesting)asdef@asdef-pc:~/Dropbox/Work/Git/PyTestError$ cd /home/asdef/Dropbox/Work/Git/PyTestError/areport4
(autotesting)asdef@asdef-pc:~/Dropbox/Work/Git/PyTestError/areport4$ cd /home/asdef/Dropbox/Work/Git/PyTestError
(autotesting)asdef@asdef-pc:~/Dropbox/Work/Git/PyTestError$ pytest test_3.py --alluredir areport4
========================================================================= test session starts ==========================================================================
platform linux2 -- Python 2.7.8, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
metadata: {'Python': '2.7.8', 'Platform': 'Linux-4.4.0-85-generic-x86_64-with-Ubuntu-14.04-trusty', 'Packages': {'py': '1.4.34', 'pytest': '3.1.3', 'pluggy': '0.4.0'}, 'JAVA_HOME': '/usr/lib/jvm/java-8-oracle', 'Plugins': {'xdist': '1.18.1', 'allure-pytest': '2.1.0b1', 'html': '1.14.2', 'PyTestTelegramReport': '0.0.7', 'instafail': '0.3.0', 'metadata': '1.5.0'}}
rootdir: /home/asdef/Dropbox/Work/Git/PyTestError, inifile:
plugins: xdist-1.18.1, metadata-1.5.0, instafail-0.3.0, html-1.14.2, allure-pytest-2.1.0b1, PyTestTelegramReport-0.0.7
collected 1 item s

test_3.py .
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/main.py", line 105, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/main.py", line 141, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/main.py", line 164, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_pytest/listener.py", line 78, in pytest_runtest_protocol
INTERNALERROR>     self.allure_logger.close_test(uuid)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_commons/logger.py", line 67, in close_test
INTERNALERROR>     test_case.write(self._report_dir)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_commons/model2.py", line 69, in write
INTERNALERROR>     _write(report_dir, self, TEST_CASE_PATTERN)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_commons/model2.py", line 23, in _write
INTERNALERROR>     json_file.write(unicode(json.dumps(data, indent=indent, ensure_ascii=False, encoding='utf8')))
INTERNALERROR>   File "/usr/lib/python2.7/json/__init__.py", line 250, in dumps
INTERNALERROR>     sort_keys=sort_keys, **kw).encode(obj)
INTERNALERROR>   File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
INTERNALERROR>     chunks = self.iterencode(o, _one_shot=True)
INTERNALERROR>   File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
INTERNALERROR>     return _iterencode(o, 0)
INTERNALERROR>   File "/usr/lib/python2.7/json/encoder.py", line 233, in _encoder
INTERNALERROR>     o = o.decode(_encoding)
INTERNALERROR>   File "/home/asdef/.virtualenvs/autotesting/lib/python2.7/encodings/utf_8.py", line 16, in decode
INTERNALERROR>     return codecs.utf_8_decode(input, errors, True)
INTERNALERROR> UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: invalid start byte

======================================================================= 1 passed in 0.70 seconds =======================================================================

# Fixed code
def __enter__(self):
    args, kwargs = self.params
    args.update(kwargs)
    params = list(args.items())
    plugin_manager.hook.start_step(uuid=self.uuid, title=self.title, params=params)