Bug: "Error in atexit._run_exitfuncs" when running unit tests
See original GitHub issueDescription
I’m using the package within a download function like so:
def download(url):
spinner = Halo(text='Downloading', spinner='dots12')
spinner.start()
(...)
spinner.succeed('Download Complete')
spinner.stop()
While, the package works as expected when running the program, when running unit test with pytest the test output is followed by the error message pasted below.
System settings
- Operating System: macOS
- Terminal in use: iTerm2
- Python version: 3.5, 3.6, 3.7
- Halo version: 0.0.17
pip freeze
output:
Error
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 78, in clean_up
self.stop()
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 419, in stop
self.clear()
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 311, in clear
self._stream.write('\r')
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
self.__convertor.write(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
self.__convertor.write(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "/usr/local/lib/python3.7/site-packages/_pytest/capture.py", line 358, in write
self.buffer.write(obj)
ValueError: I/O operation on closed file
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 78, in clean_up
self.stop()
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 419, in stop
self.clear()
File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 311, in clear
self._stream.write('\r')
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
self.__convertor.write(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
self.__convertor.write(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "/usr/local/lib/python3.7/site-packages/_pytest/capture.py", line 358, in write
self.buffer.write(obj)
ValueError: I/O operation on closed file
Expected behaviour
I wouldn’t expect the package to have any impact on these tests that isn’t present when running the program.
Steps to recreate
- Run pytest unit tests on a program that uses halo as shown above
People to notify
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Error in atexit._run_exitfuncs: (#1007) - openpyxl - Projects
Hi everyone,. I discovered an issue when testing an openpyxl 2.5.1 application with setup.py and py.test. It occurs when using Python 2.7.14. It ......
Read more >Python Multiprocessing atexit Error "Error in ... - Stack Overflow
This is a very old question, but it seems like the accepted answer does not actually fix the problem. The main issue is...
Read more >Error in atexit._run_exitfuncs with setup.py, nose.collector and ...
All my test pass just fine and this bug only appears when I run 'python setup.py test'. Running nose directly from nosetests doesn't...
Read more >Testing Python in Visual Studio Code
Running the unit test early and often means that you quickly catch regressions, which are unexpected changes in the behavior of code that...
Read more >Xcode 12 issues running multiple t… | Apple Developer Forums
xctest encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here ya go (just hit run): https://repl.it/repls/SorrowfulNaturalDisassembler
“Better” in what sense? If the intent of the
atexit
handler is to cleanup something, and it’s already cleaned up, is there anything else to do?