I create new virtualenv, import unittest in shell, try to import test from unittest, get an error I need unittest.test for my project what should I do?
max24@LAPTOP-6RUMBKO8:~$ virtualenv test2
created virtual environment CPython3.8.10.final.0-64 in 196ms
creator CPython3Posix(dest=/home/max24/test2, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/max24/.local/share/virtualenv)
added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
max24@LAPTOP-6RUMBKO8:~$ source test2/bin/activate
(test2) max24@LAPTOP-6RUMBKO8:~$ python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import unittest
>>> from unittest import test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'test' from 'unittest' (/usr/lib/python3.8/unittest/__init__.py)
>>>```
test
isn't a thing. So just don't dofrom unittest import test
. Also, you should write your test in a file that you can run. Check out this example for the correct way to use unittest. – Code-Apprenticefrom unittest.test.support import LoggingResult
and it throwNo module named 'unittest.test
– begletsoidunittest.test
isn't a module in the standardunittest
module. If you have a folderunittest/test
in your project, then you need to say so and describe the rest of your project's directory structure. Check out How to Ask for some more tips on how to improve your question. – Code-Apprentice