# Problem in tests

**URL:** https://forum.djangoproject.com/t/problem-in-tests/24414
**Category:** Getting Started
**Created:** [October 9, 2023, 7:50am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414 "2023-10-09T07:50:37Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 9, 2023, 7:50am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/1 "2023-10-09T07:50:37Z")

</div>

I have just learned django these days and make a project similar to tutorial.Before i start my project,i copied tutorial code and run,but programe erred when run tests.py(tutorial05),and now it happens again.  
I have added my app name in settings.py,and the errors are below:  
**1.run tests.py**

```auto
Error
Traceback (most recent call last):
Failure: builtins.tuple: (<class 'django.core.exceptions.ImproperlyConfigured'>, ImproperlyConfigured('Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.'), <traceback object at 0x000001D2BDC66080>)

```

**2.use ‘python manage.py test TA’ in terminal**

```auto
Found 1 test(s).
System check identified no issues (0 silenced).
E
======================================================================
ERROR: djangoproject.TA (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: djangoproject.TA
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 377, in _get_module_from_name
    __import__ (name)
ModuleNotFoundError: No module named 'djangoproject.TA'

```

How can i solve this problem?Please help!

---

<div class="post-metadata">

### Author: ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)
#### Post date: [October 9, 2023, 8:33am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/2 "2023-10-09T08:33:15Z")

</div>

Can you share your installed\_apps setting?

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 9, 2023, 8:39am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/3 "2023-10-09T08:39:01Z")

</div>

```auto
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'appA',
    'TA',
]

```

I also tried to change ‘TA’ to ‘TA.apps.TAConfig’,but it did’t work too.

---

<div class="post-metadata">

### Author: ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)
#### Post date: [October 9, 2023, 8:52am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/4 "2023-10-09T08:52:33Z")

</div>

Share your project folder structure from root folder

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 9, 2023, 9:57am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/5 "2023-10-09T09:57:18Z")

</div>

![QQ图片20231009175645](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/1/2/12f7ee478ab7888ee712203aa2ade2346ce544e3.png)

---

<div class="post-metadata">

### Author: ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)
#### Post date: [October 9, 2023, 10:02am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/6 "2023-10-09T10:02:24Z")

</div>

Okay, are you using virtualenv or env or any other environment?  
Also what is your OS

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 9, 2023, 10:17am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/7 "2023-10-09T10:17:36Z")

</div>

win11,i’m using virtualenv download in pycharm,is it result in error?

---

<div class="post-metadata">

### Author: ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)
#### Post date: [October 9, 2023, 11:24am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/8 "2023-10-09T11:24:29Z")

</div>

> [@doubidoubidou](#):
>
> is it result in error?

No  
Have you activated virtualenv and which one of the given folder is your virtualenv folder?

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 9, 2023, 11:38am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/9 "2023-10-09T11:38:48Z")

</div>

I do my project in another computer,how can i judge if my virtualenv is activated?

---

<div class="post-metadata">

### Author: ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)
#### Post date: [October 9, 2023, 12:43pm UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/10 "2023-10-09T12:43:05Z")

</div>

In your terminal where you are running your command python manage.py runserver there you can see if the environment directory is activated  
something like this, here you can see `(env)` which is my environment folder where everything is installed for this particular project.

```auto
jlp-020@jlp020:~/Projects/POC-SingleVendor-BookanAppointment-BE$ source env/bin/activate
(env) jlp-020@jlp020:~/Projects/POC-SingleVendor-BookanAppointment-BE$ 

```

Note: I’m using ubuntu os, in windows there is different command to activate and even creating a virtualenv

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 10, 2023, 12:16am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/11 "2023-10-10T00:16:51Z")

</div>

Hi,i think my venv is already activated by pycharm,my terminal prefix shows ‘venv’  
`(venv) PS C:\Users\user\PycharmProjects\pythonProject\djangoproject>`

---

<div class="post-metadata">

### Author: ![doubidoubidou](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doubidoubidou/32/16344_2.png) [@doubidoubidou](https://forum.djangoproject.com/u/doubidoubidou)
#### Post date: [October 10, 2023, 12:31am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/12 "2023-10-10T00:31:37Z")

</div>

In addition,i can run python manage.py test TA.tests,but it can’t find my testcase

```auto
(venv) PS C:\Users\user\PycharmProjects\pythonProject\djangoproject> python manage.py test TA.tests
Found 0 test(s).
System check identified no issues (0 silenced).
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK

```

My testcase is below,‘ssex’ is limited CharField(max\_length=1)

```auto
class StudentModelTest(TestCase):
    def judgesex(self):
        student=Student(sno='001',sname='ggg',sage=23,ssex='Male',sbirth='2000-09-19')
        self.assertIsInstance(student,Student)

```

---

<div class="post-metadata">

### Author: ![AngryChocobo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/angrychocobo/32/16511_2.png) [@AngryChocobo](https://forum.djangoproject.com/u/AngryChocobo)
#### Post date: [October 19, 2023, 8:41am UTC](https://forum.djangoproject.com/t/problem-in-tests/24414/13 "2023-10-19T08:41:58Z")

</div>

When you [run your tests](https://docs.djangoproject.com/en/4.2/topics/testing/overview/#running-tests), the default behavior of the test utility is to find all the test cases (that is, subclasses of [`unittest.TestCase`](https://docs.python.org/3/library/unittest.html#unittest.TestCase)) in any file whose name begins with `test` , automatically build a test suite out of those test cases, and run that suite.

```python
 def test_judgesex(self):
     student=Student(sno='001',sname='ggg',sage=23,ssex='Male',sbirth='2000-09-19')
        self.assertIsInstance(student,Student)

```
