0
votes

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)
>>>```
The error tells you that test isn't a thing. So just don't do from 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-Apprentice
I am not using any tutorial, I am working with a project whose files have from unittest.test.support import LoggingResult and it throw No module named 'unittest.testbegletsoid
Please include more details in your question. The error tells you the problem: unittest.test isn't a module in the standard unittest module. If you have a folder unittest/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