AttributeError: 'TerminalWriter' object has no attribute '_write_source' while executing Module 23 Data driven framework - PART 1 | Selenium Python Forum
M
M Prabhaharan Posted on 16/05/2020

from selenium import webdriver
import pytest

@pytest.mark.run()
def test_A1():
assert False

@pytest.mark.run()
def test_A2():
assert True

@pytest.mark.run()
def test_A3():
assert True

 

 

----------------

platform win32 -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\prabha\eclipse-workspace\SeleniumTest
plugins: allure-pytest-2.8.13
collected 3 items

--------------------

 


DataDrivenPackage\test_dummy.py F
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\main.py", line 191, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\main.py", line 247, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\main.py", line 272, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\runner.py", line 85, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\runner.py", line 100, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\runner.py", line 190, in call_and_report
INTERNALERROR> hook.pytest_runtest_logreport(report=report)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\prabha\.p2\pool\plugins\org.python.pydev.core_7.5.0.202001101138\pysrc\_pydev_runfiles\pydev_runfiles_pytest2.py", line 243, in pytest_runtest_logreport
INTERNALERROR> exc = _get_error_contents_from_report(report)
INTERNALERROR> File "C:\Users\prabha\.p2\pool\plugins\org.python.pydev.core_7.5.0.202001101138\pysrc\_pydev_runfiles\pydev_runfiles_pytest2.py", line 147, in _get_error_contents_from_report
INTERNALERROR> report.toterminal(tw)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\reports.py", line 65, in toterminal
INTERNALERROR> longrepr.toterminal(out)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\_code\code.py", line 962, in toterminal
INTERNALERROR> element[0].toterminal(tw)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\_code\code.py", line 992, in toterminal
INTERNALERROR> entry.toterminal(tw)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\_code\code.py", line 1080, in toterminal
INTERNALERROR> self._write_entry_lines(tw)
INTERNALERROR> File "C:\Users\prabha\AppData\Local\Programs\Python\Python37\lib\site-packages\_pytest\_code\code.py", line 1062, in _write_entry_lines
INTERNALERROR> tw._write_source(source_lines, indents)
INTERNALERROR> AttributeError: 'TerminalWriter' object has no attribute '_write_source'

======================== 1 failed, 3 warnings in 0.39s ========================

 

 

please provide soultion if any body has


K
Kam Replied on 18/05/2020

I am getting this error all time, dont understand why is it coming up, and how to resolve it? After error, testcase stops, and NO Allure report is generated. 


0
09914040666 Replied on 19/05/2020

Hey, 

The error who are facing can be result of different version of pytest. Please try using older version of pytest by uninstalling it from cmd using the command "pip uninstall pytest" and installing the older version again and try running the code.


K
Kam Replied on 20/05/2020

which older version I need to install, and what is command?


0
09914040666 Replied on 20/05/2020

Hey, 

Use the command "pip install pytest==5.3.5"


K
Kam Replied on 21/05/2020

Thanks, It looks issue is resolved. 


0
09914040666 Replied on 16/07/2020

Hey, 

Thank you for the update.


Related Posts