When i run the command “python manage.py test” I am getting the list of errors like this (beloved)
I can run a simple test in my application (shop) with the command “python manage.py test shop”
from django.test import SimpleTestCase
class TestSimpleCase(SimpleTestCase):
def test1(self):
assert 1 == 2
def test2(self):
assert 2 == 2
assert 1 == 2
^^^^^^
AssertionError
But when I am trying to create test that relates to the application like:
from django.test import SimpleTestCase
from django.urls import resolve, reverse
from shop.views import product_list
class TestUrls(SimpleTestCase):
def test1(self):
url = reverse('product_list')
print(resolve(url))
path(‘’, views.product_list, name=‘product_list’),
I am getting this error:
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for ‘product_list’ not found. ‘product_list’ is not a valid view function or pattern name.
Ran 1 test in 0.007s
LIST OF ERROR AFTER RUNNING “python manage.py test”
Found 9 test(s).
System check identified no issues (0 silenced).
EEEEEEEEE
ERROR: myshop.accounts (unittest.loader._FailedTest.myshop.accounts)
ImportError: Failed to import test module: myshop.accounts
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.accounts’
======================================================================
ERROR: myshop.api (unittest.loader._FailedTest.myshop.api)
ImportError: Failed to import test module: myshop.api
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.api’
======================================================================
ERROR: myshop.cart (unittest.loader._FailedTest.myshop.cart)
ImportError: Failed to import test module: myshop.cart
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.cart’
======================================================================
ERROR: myshop.coupons (unittest.loader._FailedTest.myshop.coupons)
ImportError: Failed to import test module: myshop.coupons
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.coupons’
======================================================================
ERROR: myshop.myshop (unittest.loader._FailedTest.myshop.myshop)
ImportError: Failed to import test module: myshop.myshop
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.myshop’
======================================================================
ERROR: myshop.order (unittest.loader._FailedTest.myshop.order)
ImportError: Failed to import test module: myshop.order
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.order’
======================================================================
ERROR: myshop.payment (unittest.loader._FailedTest.myshop.payment)
ImportError: Failed to import test module: myshop.payment
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.payment’
======================================================================
ERROR: myshop.shop_info (unittest.loader._FailedTest.myshop.shop_info)
ImportError: Failed to import test module: myshop.shop_info
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.shop_info’
======================================================================
ERROR: myshop.shopcontact (unittest.loader._FailedTest.myshop.shopcontact)
ImportError: Failed to import test module: myshop.shopcontact
Traceback (most recent call last):
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 440, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Kacper\AppData\Local\Programs\Python\Python311\Lib\unittest\loader.py”, line 350, in _get_module_from_name
import(name)
ModuleNotFoundError: No module named ‘myshop.shopcontact’
Ran 9 tests in 0.001s
FAILED (errors=9)
FIle structure