# Mock pty / termios on windows tests

**URL:** <https://discuss.python.org/t/mock-pty-termios-on-windows-tests/14394>\
**Category:** Python Help\
**Tags:** help\
**Created:** [March 17, 2022, 4:34pm UTC](https://discuss.python.org/t/mock-pty-termios-on-windows-tests/14394 "2022-03-17T16:34:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZeeD](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zeed/32/3547_2.png) [@ZeeD](https://discuss.python.org/u/ZeeD)\
**Post date:** [March 17, 2022, 4:34pm UTC](https://discuss.python.org/t/mock-pty-termios-on-windows-tests/14394/1 "2022-03-17T16:34:18Z")

</div>

I am developing an application that it’s meant to be run on linux, and relies on `pty` and `termios` modules (I don’t think it’s important, but I’m writing some DAGs on Airflow).  
I use a windows workstation.  
I would like to run the unit tests on my local machine, and I’m trying to use `unittest.mock.patch` to prevent the import of the (non existent on my OS) modules.

Still, I have problems, and I don’t know how to setup the import to avoid errors.

a minimal example is

lib.py

```python
import termios
class C: ...

```

foo.py

```python
from lib import C
def bar(): ...

```

test\_foo.py

```python
import foo
def test_foo_bar():
    assert foo.bar() == ...

```

what “magic” should I write in test\_foo to avoid the error

```nohighlight
>pytest test_foo.py
============================================================================================ test session starts =============================================================================================
platform win32 -- Python 3.7.9, pytest-7.0.1, pluggy-1.0.0
rootdir: C:\Users\vito.detullio\Desktop\workspace-srm-cognitive\be-airflow-dags, configfile: pytest.ini
plugins: anyio-3.4.0, cov-3.0.0
collected 0 items / 1 error                                                                                                                                                                                   

=================================================================================================== ERRORS ===================================================================================================
_____________________________________________________________________________________ERROR collecting delme/test_foo.py_____________________________________________________________________________________
ImportError while importing test module 'C:\Users\vito.detullio\Desktop\workspace-srm-cognitive\be-airflow-dags\delme\test_foo.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
c:\Program Files\Python37\lib\importlib\ __init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_foo.py:1: in <module>
    import foo
foo.py:1: in <module>
    from lib import C
lib.py:1: in <module>
    import termios
E ModuleNotFoundError: No module named 'termios'
========================================================================================== short test summary info ===========================================================================================
ERROR test_foo.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================== 1 error in 0.14s ==============================================================================================

```
