OSError: [Errno 25] Inappropriate ioctl for device when running in pytest
See original GitHub issueA project of mine uses alive-progress
. I updated from 1.6.2
to 2.1.0
and the above error was raised when I ran my tests. I tried running the test in different terminals - iterm2, vscode and pycharm but got the same exception. Below is the stack trace for the same.
tests/test_base.py::test_pipeline_with_default_reader
/Users/saifkazi/Desktop/preprocessy/venv/lib/python3.9/site-packages/_pytest/threadexception.py:75: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-1
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/Users/saifkazi/Desktop/preprocessy/venv/lib/python3.9/site-packages/alive_progress/core/progress.py", line 112, in run
alive_repr(next(spinner_player))
File "/Users/saifkazi/Desktop/preprocessy/venv/lib/python3.9/site-packages/alive_progress/core/progress.py", line 123, in alive_repr
run.last_len = print_cells(fragments, term.cols(), run.last_len, _term=term)
File "/Users/saifkazi/Desktop/preprocessy/venv/lib/python3.9/site-packages/alive_progress/utils/terminal/tty.py", line 32, in cols
return os.get_terminal_size()[0]
OSError: [Errno 25] Inappropriate ioctl for device
The code that uses alive-progress
def process(self):
"""Method that executes the pipeline sequentially."""
self.print_info()
with alive_bar(
len(self.steps),
title="Pipeline Stages",
enrich_print=False,
force_tty=True,
) as bar:
print("\nProcessing...\n")
for step in self.steps:
step(self.params)
print(
f"==> Completed Stage: {stringcase.sentencecase(step.__name__)}\n"
)
bar()
print(
Fore.GREEN + "\nPipeline Completed Successfully\n" + Style.RESET_ALL
)
The test for above
def test_pipeline_with_default_reader():
df = pd.DataFrame({"A": np.arange(1, 100), "B": np.arange(1, 100)})
_ = df.to_csv("./datasets/configs/dataset.csv", index=False)
params = {
"col_1": "A",
"col_2": "B",
"test_size": 0.2,
}
pipeline = BasePipeline(
train_df_path="./datasets/configs/dataset.csv",
steps=[times_two, squared, split],
params=params,
)
pipeline.process()
assert "train_df" in pipeline.params.keys()
Version Numbers
Python - 3.8, 3.9 alive-progress - 2.1.0
From what I could debug, this has something to do with utils/terminal/tty.py
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
IOError: [Errno 25] Inappropriate ioctl for device - Stack Overflow
This would happen if stdout isn't a terminal (e,g,, redirecting to a file or run as a subprocess and its a pipe). There...
Read more >When trying to run 'poetry shell' on github CI, I get a (25 ...
The inappropriate ioctl is because Poetry is using a library to manipulate the pty, and this fails when stdout is not a pty....
Read more >Handling OSError exception in Python - GeeksforGeeks
OSError is a built-in exception in Python and serves as the error class for the os ... OSError: [Errno 25] Inappropriate ioctl for...
Read more >Changelog — pytest documentation
#10060: When running with --pdb , TestCase.tearDown is no longer called for tests when the class has been skipped via unittest.skip or pytest.mark.skip...
Read more >pytest Documentation - Read the Docs
pytest will run all files of the form test_*.py or *_test.py in the current directory and its subdirectories. More generally,.
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
Nice, as I thought… And great that it works with the default value of
force_tty
. But unfortunately I don’t know of any fix for that. I even tried to search about it, but couldn’t find anything relevant…No, not at all! You won’t miss out anything! This param exists just as a workaround for terminals that do not report themselves as “interactive”, such as Pycharm’s terminal and Jupyter Notebook. So, if you’re running your software anywhere else, it won’t make any difference 👍
I’ll close this ticket than, but feel free to reply if you want.
Yes, the test broke on the first line itself as you mentioned. Is there a workaround to this? Setting
force_tty = None
, fixes the running of tests. But are there any side effects to doing so? Right now withforce_tty
at its default value, satisfies all my use cases, but is there some feature that I’ll miss out on by doing this?