Django. AttributeError when running migrations on test database before tests in docker
Long story short, I am trying to run tests inside docker container like:
./manage.py test
but getting error:
/app/gauss # ./manage.py test
nosetests --where=tests/ --verbosity=2 --with-coverage --cover-package=gauss.catalogues --cover-package=gauss.requests --cover-package=gauss.core --cover-xml --cover-xml-file=gauss_coverage.xml --with-xunit --xunit-file=gauss_xunit.xml
Creating test database for alias 'default'...
/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py:259: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the default database instead.
RuntimeWarning
Got an error creating the test database: database "test_gauss" already exists
Type 'yes' if you would like to try deleting the test database 'test_gauss', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
...
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 13, in <module>
class Migration(migrations.Migration):
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 57, in Migration
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url], verbose_name='web_url')),
AttributeError: module 'gauss' has no attribute 'catalogues'
'gauss' is my django-project name and 'catalogoues' is app inside it. Error do not appers when I am running same command on my local computer.
All project structure:
Project settings:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django_nose',
'mptt',
'sorl.thumbnail',
'rest_framework',
'webpack_loader',
'gauss.catalogues',
'gauss.ui.general',
'gauss.requests'
]
...
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--where=tests/',
'--verbosity=2',
'--with-coverage',
'--cover-package=gauss.catalogues',
'--cover-package=gauss.requests',
'--cover-package=gauss.core',
'--cover-xml',
'--cover-xml-file=gauss_coverage.xml',
'--with-xunit',
'--xunit-file=gauss_xunit.xml',
]
Part of migrations file that causing error:
# Generated by Django 2.0.2 on 2018-09-04 12:17
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import gauss.catalogues.model_fields
import gauss.catalogues.validators
import mptt.fields
class Migration(migrations.Migration):
..
migrations.CreateModel(
name='GSClient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deleted', models.BooleanField(default=False)),
('added_date', models.DateTimeField(blank=True, null=True)),
('name', models.CharField(max_length=100, verbose_name='Название')),
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url],)),
('email_domain', models.CharField(max_length=100, validators=[gauss.catalogues.validators.domain_validator], verbose_name='Почтовый домен')),
],
options=
'db_table': 'gs_catalogues_clients',
,
),
Model that causing error
from django.db import models
from django.core.exceptions import ValidationError
from django.contrib.contenttypes.models import ContentType
from gauss.catalogues import validators, model_fields
from gauss.core import mixins
class GSClient(mixins.DeletedMixin, mixins.GSAddedDateMixin, models.Model):
name = models.CharField(
max_length=100,
)
web_url = models.CharField(
max_length=100,
blank=True,
validators=[validators.validate_url],
)
email_domain = models.CharField(
max_length=100,
validators=[validators.domain_validator],
blank=False,
null=False,
)
structure = models.ForeignKey(
'catalogues.GSClientStructure',
null=True,
related_name="structure_client",
on_delete=models.SET_NULL,
)
class Meta:
db_table = "gs_catalogues_clients"
I checked all attributes of module 'gauss' from shell and it's has module catalogues:
>>> import gauss
>>> print(gauss)
<module 'gauss' from '/app/gauss/gauss/__init__.py'>
>>> print(gauss.catalogues)
<module 'gauss.catalogues' from '/app/gauss/gauss/catalogues/__init__.py'>
>>> print(dir(gauss))
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'catalogues', 'core', 'requests', 'settings', 'settings_local', 'ui']
python django docker
add a comment |
Long story short, I am trying to run tests inside docker container like:
./manage.py test
but getting error:
/app/gauss # ./manage.py test
nosetests --where=tests/ --verbosity=2 --with-coverage --cover-package=gauss.catalogues --cover-package=gauss.requests --cover-package=gauss.core --cover-xml --cover-xml-file=gauss_coverage.xml --with-xunit --xunit-file=gauss_xunit.xml
Creating test database for alias 'default'...
/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py:259: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the default database instead.
RuntimeWarning
Got an error creating the test database: database "test_gauss" already exists
Type 'yes' if you would like to try deleting the test database 'test_gauss', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
...
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 13, in <module>
class Migration(migrations.Migration):
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 57, in Migration
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url], verbose_name='web_url')),
AttributeError: module 'gauss' has no attribute 'catalogues'
'gauss' is my django-project name and 'catalogoues' is app inside it. Error do not appers when I am running same command on my local computer.
All project structure:
Project settings:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django_nose',
'mptt',
'sorl.thumbnail',
'rest_framework',
'webpack_loader',
'gauss.catalogues',
'gauss.ui.general',
'gauss.requests'
]
...
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--where=tests/',
'--verbosity=2',
'--with-coverage',
'--cover-package=gauss.catalogues',
'--cover-package=gauss.requests',
'--cover-package=gauss.core',
'--cover-xml',
'--cover-xml-file=gauss_coverage.xml',
'--with-xunit',
'--xunit-file=gauss_xunit.xml',
]
Part of migrations file that causing error:
# Generated by Django 2.0.2 on 2018-09-04 12:17
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import gauss.catalogues.model_fields
import gauss.catalogues.validators
import mptt.fields
class Migration(migrations.Migration):
..
migrations.CreateModel(
name='GSClient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deleted', models.BooleanField(default=False)),
('added_date', models.DateTimeField(blank=True, null=True)),
('name', models.CharField(max_length=100, verbose_name='Название')),
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url],)),
('email_domain', models.CharField(max_length=100, validators=[gauss.catalogues.validators.domain_validator], verbose_name='Почтовый домен')),
],
options=
'db_table': 'gs_catalogues_clients',
,
),
Model that causing error
from django.db import models
from django.core.exceptions import ValidationError
from django.contrib.contenttypes.models import ContentType
from gauss.catalogues import validators, model_fields
from gauss.core import mixins
class GSClient(mixins.DeletedMixin, mixins.GSAddedDateMixin, models.Model):
name = models.CharField(
max_length=100,
)
web_url = models.CharField(
max_length=100,
blank=True,
validators=[validators.validate_url],
)
email_domain = models.CharField(
max_length=100,
validators=[validators.domain_validator],
blank=False,
null=False,
)
structure = models.ForeignKey(
'catalogues.GSClientStructure',
null=True,
related_name="structure_client",
on_delete=models.SET_NULL,
)
class Meta:
db_table = "gs_catalogues_clients"
I checked all attributes of module 'gauss' from shell and it's has module catalogues:
>>> import gauss
>>> print(gauss)
<module 'gauss' from '/app/gauss/gauss/__init__.py'>
>>> print(gauss.catalogues)
<module 'gauss.catalogues' from '/app/gauss/gauss/catalogues/__init__.py'>
>>> print(dir(gauss))
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'catalogues', 'core', 'requests', 'settings', 'settings_local', 'ui']
python django docker
add a comment |
Long story short, I am trying to run tests inside docker container like:
./manage.py test
but getting error:
/app/gauss # ./manage.py test
nosetests --where=tests/ --verbosity=2 --with-coverage --cover-package=gauss.catalogues --cover-package=gauss.requests --cover-package=gauss.core --cover-xml --cover-xml-file=gauss_coverage.xml --with-xunit --xunit-file=gauss_xunit.xml
Creating test database for alias 'default'...
/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py:259: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the default database instead.
RuntimeWarning
Got an error creating the test database: database "test_gauss" already exists
Type 'yes' if you would like to try deleting the test database 'test_gauss', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
...
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 13, in <module>
class Migration(migrations.Migration):
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 57, in Migration
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url], verbose_name='web_url')),
AttributeError: module 'gauss' has no attribute 'catalogues'
'gauss' is my django-project name and 'catalogoues' is app inside it. Error do not appers when I am running same command on my local computer.
All project structure:
Project settings:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django_nose',
'mptt',
'sorl.thumbnail',
'rest_framework',
'webpack_loader',
'gauss.catalogues',
'gauss.ui.general',
'gauss.requests'
]
...
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--where=tests/',
'--verbosity=2',
'--with-coverage',
'--cover-package=gauss.catalogues',
'--cover-package=gauss.requests',
'--cover-package=gauss.core',
'--cover-xml',
'--cover-xml-file=gauss_coverage.xml',
'--with-xunit',
'--xunit-file=gauss_xunit.xml',
]
Part of migrations file that causing error:
# Generated by Django 2.0.2 on 2018-09-04 12:17
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import gauss.catalogues.model_fields
import gauss.catalogues.validators
import mptt.fields
class Migration(migrations.Migration):
..
migrations.CreateModel(
name='GSClient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deleted', models.BooleanField(default=False)),
('added_date', models.DateTimeField(blank=True, null=True)),
('name', models.CharField(max_length=100, verbose_name='Название')),
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url],)),
('email_domain', models.CharField(max_length=100, validators=[gauss.catalogues.validators.domain_validator], verbose_name='Почтовый домен')),
],
options=
'db_table': 'gs_catalogues_clients',
,
),
Model that causing error
from django.db import models
from django.core.exceptions import ValidationError
from django.contrib.contenttypes.models import ContentType
from gauss.catalogues import validators, model_fields
from gauss.core import mixins
class GSClient(mixins.DeletedMixin, mixins.GSAddedDateMixin, models.Model):
name = models.CharField(
max_length=100,
)
web_url = models.CharField(
max_length=100,
blank=True,
validators=[validators.validate_url],
)
email_domain = models.CharField(
max_length=100,
validators=[validators.domain_validator],
blank=False,
null=False,
)
structure = models.ForeignKey(
'catalogues.GSClientStructure',
null=True,
related_name="structure_client",
on_delete=models.SET_NULL,
)
class Meta:
db_table = "gs_catalogues_clients"
I checked all attributes of module 'gauss' from shell and it's has module catalogues:
>>> import gauss
>>> print(gauss)
<module 'gauss' from '/app/gauss/gauss/__init__.py'>
>>> print(gauss.catalogues)
<module 'gauss.catalogues' from '/app/gauss/gauss/catalogues/__init__.py'>
>>> print(dir(gauss))
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'catalogues', 'core', 'requests', 'settings', 'settings_local', 'ui']
python django docker
Long story short, I am trying to run tests inside docker container like:
./manage.py test
but getting error:
/app/gauss # ./manage.py test
nosetests --where=tests/ --verbosity=2 --with-coverage --cover-package=gauss.catalogues --cover-package=gauss.requests --cover-package=gauss.core --cover-xml --cover-xml-file=gauss_coverage.xml --with-xunit --xunit-file=gauss_xunit.xml
Creating test database for alias 'default'...
/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py:259: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the default database instead.
RuntimeWarning
Got an error creating the test database: database "test_gauss" already exists
Type 'yes' if you would like to try deleting the test database 'test_gauss', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
...
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 13, in <module>
class Migration(migrations.Migration):
File "/app/gauss/gauss/catalogues/migrations/0001_initial.py", line 57, in Migration
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url], verbose_name='web_url')),
AttributeError: module 'gauss' has no attribute 'catalogues'
'gauss' is my django-project name and 'catalogoues' is app inside it. Error do not appers when I am running same command on my local computer.
All project structure:
Project settings:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django_nose',
'mptt',
'sorl.thumbnail',
'rest_framework',
'webpack_loader',
'gauss.catalogues',
'gauss.ui.general',
'gauss.requests'
]
...
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--where=tests/',
'--verbosity=2',
'--with-coverage',
'--cover-package=gauss.catalogues',
'--cover-package=gauss.requests',
'--cover-package=gauss.core',
'--cover-xml',
'--cover-xml-file=gauss_coverage.xml',
'--with-xunit',
'--xunit-file=gauss_xunit.xml',
]
Part of migrations file that causing error:
# Generated by Django 2.0.2 on 2018-09-04 12:17
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import gauss.catalogues.model_fields
import gauss.catalogues.validators
import mptt.fields
class Migration(migrations.Migration):
..
migrations.CreateModel(
name='GSClient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deleted', models.BooleanField(default=False)),
('added_date', models.DateTimeField(blank=True, null=True)),
('name', models.CharField(max_length=100, verbose_name='Название')),
('web_url', models.CharField(blank=True, max_length=100, validators=[gauss.catalogues.validators.validate_url],)),
('email_domain', models.CharField(max_length=100, validators=[gauss.catalogues.validators.domain_validator], verbose_name='Почтовый домен')),
],
options=
'db_table': 'gs_catalogues_clients',
,
),
Model that causing error
from django.db import models
from django.core.exceptions import ValidationError
from django.contrib.contenttypes.models import ContentType
from gauss.catalogues import validators, model_fields
from gauss.core import mixins
class GSClient(mixins.DeletedMixin, mixins.GSAddedDateMixin, models.Model):
name = models.CharField(
max_length=100,
)
web_url = models.CharField(
max_length=100,
blank=True,
validators=[validators.validate_url],
)
email_domain = models.CharField(
max_length=100,
validators=[validators.domain_validator],
blank=False,
null=False,
)
structure = models.ForeignKey(
'catalogues.GSClientStructure',
null=True,
related_name="structure_client",
on_delete=models.SET_NULL,
)
class Meta:
db_table = "gs_catalogues_clients"
I checked all attributes of module 'gauss' from shell and it's has module catalogues:
>>> import gauss
>>> print(gauss)
<module 'gauss' from '/app/gauss/gauss/__init__.py'>
>>> print(gauss.catalogues)
<module 'gauss.catalogues' from '/app/gauss/gauss/catalogues/__init__.py'>
>>> print(dir(gauss))
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'catalogues', 'core', 'requests', 'settings', 'settings_local', 'ui']
python django docker
python django docker
edited Nov 13 '18 at 8:16
umaru
asked Nov 13 '18 at 7:45
umaruumaru
1138
1138
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Ok. I found solution. Problem is in my config
'--where=tests/'
need to be
'--where=gauss/tests/'
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276120%2fdjango-attributeerror-when-running-migrations-on-test-database-before-tests-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok. I found solution. Problem is in my config
'--where=tests/'
need to be
'--where=gauss/tests/'
add a comment |
Ok. I found solution. Problem is in my config
'--where=tests/'
need to be
'--where=gauss/tests/'
add a comment |
Ok. I found solution. Problem is in my config
'--where=tests/'
need to be
'--where=gauss/tests/'
Ok. I found solution. Problem is in my config
'--where=tests/'
need to be
'--where=gauss/tests/'
answered Nov 13 '18 at 9:38
umaruumaru
1138
1138
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276120%2fdjango-attributeerror-when-running-migrations-on-test-database-before-tests-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown