· 7 years ago · May 02, 2018, 03:02 PM
1import os
2
3from django.test import TestCase
4
5class FirstTest(TestCase):
6
7 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testje.settings")
8
9 def test_First(self):
10 a = 1
11 self.assertEqual(1, a)
12
13import os
14
15from django.test import TestCase
16
17from polls.models import Question
18
19
20class FirstTest(TestCase):
21
22 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testje.settings")
23
24 def test_First(self):
25 a = 1
26 self.assertEqual(1, a)
27
28Testing started at 16:46 ...
29C:UsersmartijnkavirtualenvsTestScriptspython.exe "C:Program FilesJetBrainsPyCharm Community Edition 2018.1.2helperspycharm_jb_unittest_runner.py" --path D:/martijnka/Downloads/testDjango/testje/polls/tests.py
30Launching unittests with arguments python -m unittest D:/martijnka/Downloads/testDjango/testje/polls/tests.py in D:martijnkaDownloadstestDjangotestjepolls
31
32Traceback (most recent call last):
33 File "C:Program FilesJetBrainsPyCharm Community Edition 2018.1.2helperspycharm_jb_unittest_runner.py", line 35, in
34 main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
35 File "c:program files (x86)python36-32Libunittestmain.py", line 94, in __init__
36 self.parseArgs(argv)
37 File "c:program files (x86)python36-32Libunittestmain.py", line 141, in parseArgs
38 self.createTests()
39 File "c:program files (x86)python36-32Libunittestmain.py", line 148, in createTests
40 self.module)
41 File "c:program files (x86)python36-32Libunittestloader.py", line 219, in loadTestsFromNames
42 suites = [self.loadTestsFromName(name, module) for name in names]
43 File "c:program files (x86)python36-32Libunittestloader.py", line 219, in
44 suites = [self.loadTestsFromName(name, module) for name in names]
45 File "c:program files (x86)python36-32Libunittestloader.py", line 153, in loadTestsFromName
46 module = __import__(module_name)
47 File "D:martijnkaDownloadstestDjangotestjepollstests.py", line 5, in
48 from polls.models import Question
49 File "D:martijnkaDownloadstestDjangotestjepollsmodels.py", line 9, in
50 class Question(models.Model):
51 File "C:UsersmartijnkavirtualenvsTestlibsite-packagesdjangodbmodelsbase.py", line 100, in __new__
52 app_config = apps.get_containing_app_config(module)
53 File "C:UsersmartijnkavirtualenvsTestlibsite-packagesdjangoappsregistry.py", line 244, in get_containing_app_config
54 self.check_apps_ready()
55 File "C:UsersmartijnkavirtualenvsTestlibsite-packagesdjangoappsregistry.py", line 127, in check_apps_ready
56 raise AppRegistryNotReady("Apps aren't loaded yet.")
57django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
58
59Process finished with exit code 1
60Empty test suite.
61
62"""
63 Django settings for testje project.
64
65 Generated by 'django-admin startproject' using Django 2.0.1.
66
67 For more information on this file, see
68 https://docs.djangoproject.com/en/2.0/topics/settings/
69
70 For the full list of settings and their values, see
71 https://docs.djangoproject.com/en/2.0/ref/settings/
72 """
73
74 import os
75
76 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
77 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
78
79
80 # Quick-start development settings - unsuitable for production
81 # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
82
83 # SECURITY WARNING: keep the secret key used in production secret!
84 SECRET_KEY = '********************************'
85
86 # SECURITY WARNING: don't run with debug turned on in production!
87 DEBUG = True
88
89 ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
90
91
92 # Application definition
93
94 INSTALLED_APPS = [
95 'polls.apps.PollsConfig',
96 'django.contrib.admin',
97 'django.contrib.auth',
98 'django.contrib.contenttypes',
99 'django.contrib.sessions',
100 'django.contrib.messages',
101 'django.contrib.staticfiles',
102 ]
103
104 MIDDLEWARE = [
105 'django.middleware.security.SecurityMiddleware',
106 'django.contrib.sessions.middleware.SessionMiddleware',
107 'django.middleware.common.CommonMiddleware',
108 'django.middleware.csrf.CsrfViewMiddleware',
109 'django.contrib.auth.middleware.AuthenticationMiddleware',
110 'django.contrib.messages.middleware.MessageMiddleware',
111 'django.middleware.clickjacking.XFrameOptionsMiddleware',
112 ]
113
114 ROOT_URLCONF = 'testje.urls'
115
116 TEMPLATES = [
117 {
118 'BACKEND': 'django.template.backends.django.DjangoTemplates',
119 'DIRS': [],
120 'APP_DIRS': True,
121 'OPTIONS': {
122 'context_processors': [
123 'django.template.context_processors.debug',
124 'django.template.context_processors.request',
125 'django.contrib.auth.context_processors.auth',
126 'django.contrib.messages.context_processors.messages',
127 ],
128 },
129 },
130 ]
131
132 WSGI_APPLICATION = 'testje.wsgi.application'
133
134
135 # Database
136 # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
137
138 DATABASES = {
139 'default': {
140 'ENGINE': 'django.db.backends.sqlite3',
141 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
142 }
143 }
144
145
146 # Password validation
147 # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
148
149 AUTH_PASSWORD_VALIDATORS = [
150 {
151 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
152 },
153 {
154 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
155 },
156 {
157 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
158 },
159 {
160 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
161 },
162 ]
163
164
165 # Internationalization
166 # https://docs.djangoproject.com/en/2.0/topics/i18n/
167
168 LANGUAGE_CODE = 'en-us'
169
170 TIME_ZONE = 'UTC'
171
172 USE_I18N = True
173
174 USE_L10N = True
175
176 USE_TZ = True
177
178
179 # Static files (CSS, JavaScript, Images)
180 # https://docs.djangoproject.com/en/2.0/howto/static-files/
181
182 STATIC_URL = '/static/'