Issue running unit test
Hi,
i'm trying to run unit test with version 2021.2.4. Below a very simple test class i made:
from mymodule import rm
import os.path
import tempfile
import unittest
class RmTestCase(unittest.TestCase):
tmpfilepath = os.path.join(tempfile.gettempdir(), "tmp-testfile")
def setUp(self):
with open(self.tmpfilepath, "wb") as f:
f.write(b"Delete me!")
def test_rm(self):
# remove the file
rm(self.tmpfilepath)
# test that it was actually removed
self.assertFalse(os.path.isfile(self.tmpfilepath), "Failed to remove the file!")
mymodule.py:
import os
def rm(filename):
os.remove(filename)
if i run test from terminal python -m unittest test_file.py no problem
but if i run from PyCharm i got this errors:
C:\Python37\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --target test_class_decorator.py::RmTestCase
Testing started at 16:41 ...
Launching pytest with arguments test_class_decorator.py::RmTestCase in C:\Users\XXXXXX\Desktop\PY_SCRIPTS\Mockito
C:\Program Files\JetBrains\PyCharm Community Edition 2020.1\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py:33: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
elif version.LooseVersion(pytest.__version__) >= version.LooseVersion("6.0"):
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\greenio\base.py", line 86, in set_nonblocking
INTERNALERROR> setblocking = fd.setblocking
INTERNALERROR> AttributeError: 'GreenFileIO' object has no attribute 'setblocking'
INTERNALERROR>
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR>
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\greenio\base.py", line 93, in set_nonblocking
INTERNALERROR> import fcntl
INTERNALERROR> File "C:\Python37\lib\site-packages\fcntl.py", line 1, in <module>
INTERNALERROR> import ffi
INTERNALERROR> ModuleNotFoundError: No module named 'ffi'
INTERNALERROR>
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR>
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Python37\lib\site-packages\_pytest\main.py", line 193, in wrap_session
INTERNALERROR> config._do_configure()
INTERNALERROR> File "C:\Python37\lib\site-packages\_pytest\config\__init__.py", line 778, in _do_configure
INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR> File "C:\Python37\lib\site-packages\pluggy\hooks.py", line 308, in call_historic
INTERNALERROR> res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\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:\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Python37\lib\site-packages\_pytest\faulthandler.py", line 25, in pytest_configure
INTERNALERROR> config.fault_handler_stderr = os.fdopen(stderr_fd_copy, "w")
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\green\os.py", line 28, in fdopen
INTERNALERROR> return greenio.GreenPipe(fd, *args, **kw)
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\greenio\py3.py", line 212, in GreenPipe
INTERNALERROR> return _open(name, mode, buffering, encoding, errors, newline, closefd, opener)
INTERNALERROR> File "C:\Python37\lib\_pyio.py", line 207, in open
INTERNALERROR> closefd, opener=opener)
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\greenio\py3.py", line 49, in __init__
INTERNALERROR> set_nonblocking(self)
INTERNALERROR> File "C:\Python37\lib\site-packages\eventlet\greenio\base.py", line 100, in set_nonblocking
INTERNALERROR> raise NotImplementedError("set_nonblocking() on a file object "
INTERNALERROR> NotImplementedError: set_nonblocking() on a file object with no setblocking() method (Windows pipes don't support non-blocking I/O)
Process finished with exit code 3
Empty suite
Can someone help me?
Please sign in to leave a comment.