django-unittest Questions
1
I am writing tests for a webapp that is made in Python3.6/Django 2.0 and I have the following situation:
class TestFoo(TestCase):
def test_a(self):
obj = Foo.objects.create(a = "bar")
expectati...
Cursive asked 9/4, 2018 at 7:7
2
I have a setting for logging in my django project and I want to make a test using assertLogs.
I used the example provided in the documentation: https://docs.python.org/3/library/unittest.html#unit...
Chlo asked 13/5, 2019 at 2:1
2
I am new to django unittest and pytest. However, I started to feel that pytest test case is more compact and clearer.
Here is my test cases:
class OrderEndpointTest(TestCase):
def setUp(self)...
Refine asked 15/6, 2017 at 3:27
2
How do you append options to the command Tox runs by appending that option to Tox? Specifically, how do you run a specific Django unittest with Tox?
I'm trying to wrap Tox around some Django unitt...
Birgitbirgitta asked 11/12, 2015 at 20:17
6
Solved
For some time now, my unit testing has been taking a longer than expected time. I have tried to debug it a couple of times without much success, as the delays are before my tests even begin to run....
Schoolbook asked 7/4, 2016 at 21:58
6
Solved
I have a model with a FileField. I want to unittest it. django test framework has great ways to manage database and emails. Is there something similar for FileFields?
How can I make sure that the ...
Ator asked 26/11, 2010 at 9:16
1
I have customized save_model admin i.e.
class MyModelAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
# some more question code here
obj.save()
Now, I would like to ...
Marilla asked 24/11, 2016 at 16:11
3
Solved
I have a unit test that's failing in an assertion that passes in another test in the same test case class.
Here's the passing test:
def test_home(self):
c = Client()
resp = c.get('/')
self.ass...
Triode asked 18/1, 2013 at 4:47
5
Solved
I'm trying to write some unit tests and run them using manage.py test but the script can't create the django_migrations table for some reason.
Here is the full error:
Creating test database for a...
Mazy asked 2/2, 2018 at 18:47
3
Under my Django project there are a few apps and all of them have unit tests. One of them that I'm working right now is supposed to be included only in dev/stage environments, so I'm enabling it us...
Tshirt asked 5/3, 2018 at 18:50
3
Solved
With the folliwing code I get this wrong result : nose.proxy.AssertionError: 302 != 200 : Couldn't retrieve redirection page '/mes_dossiers/': response code was 302 (expected 200)
what is wrong wi...
Rubadub asked 30/10, 2017 at 16:41
1
Solved
I have this Dockerfile that contains a line RUN py.test -vv.
FROM bitnami/python:3.6-prod
#MORE DIRECTIVES
RUN py.test -vv
COPY . /files
WORKDIR /files
EXPOSE 8080
When I run docker-compose buil...
Jaundice asked 7/10, 2019 at 7:9
5
I have a Django application with a view that accepts a file to be uploaded. Using the Django REST framework I'm subclassing APIView and implementing the post() method like this:
class FileUpload(A...
Cusec asked 13/6, 2014 at 9:11
2
I have a Django unit test, and I want to put print statements in it for debugging purposes but apparently django is suppressing them. How else can I print the value of a variable? I may be able to ...
Sharpshooter asked 13/5, 2013 at 23:8
1
When I do ```python -m unittest`` inside of my users app, I get this error:
TypeError: argument of type 'ConnectionHandler' is not iterable
I was customizing my User model in django and I wanted...
Velarium asked 6/6, 2019 at 20:28
1
Solved
I have django application 2.1.7 with django-tenant plugin (creating schemas in the database for saas).
My problem is unit testing. I run the command:
python manage.py test --settings=project.setti...
Battaglia asked 28/4, 2019 at 21:42
3
Solved
This is my directory:
CMSApp/tests/test_page.py
CMSApp/tests/test_user.py
CMSApp/models.py
CMSApp/views.py
I want to test test_page.py only. I can do this:
python manage.py test CMSApp/tests
...
Ceporah asked 27/10, 2015 at 21:34
0
Django needs setup code so unit tests on models that need a database will work. Standard Django unit test do that silently in the background but not with Visual Studio. I have not found a good way ...
Pappose asked 8/12, 2018 at 2:17
3
Solved
I'm trying to learn unit testing with Django/unittest.
These are simple versions of my models:
class Device(models.Model):
name = models.CharField(max_length=100)
def get_ips(self):
return De...
Lamblike asked 13/11, 2013 at 23:5
2
Solved
I am writing a unit test for Django views.
class TestLog(unittest.TestCase):
"""Test for Contact"""
def setUp(self):
self.c = Client()
try:
self.bob = User.objects.create_user("mojo","[email&...
Pilsen asked 9/6, 2011 at 10:5
1
Solved
I am using oauth2_provider for my rest_framework. I am trying to write test case for my api. I have obtained an access token. But I am not able to authenticate user using access token in APIClient
...
Dextrogyrate asked 4/6, 2018 at 10:35
4
Solved
I have a class based view
class HomePage(View):
def get(self, request):
return HttpResponse('<p>This is content.</p>')
and url-pattern defined as below:
urlpatterns = patterns('',...
Weber asked 5/12, 2014 at 16:50
1
Solved
When I run python manage.py test, django is asking a strange question each time:
$ python manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: (104...
Rothberg asked 24/11, 2017 at 4:0
2
Solved
I am trying to bring a Django project from version 1.8 to 1.11. Pretty much everything seems to work fine except unit tests. We have a base test class inheriting from Django TestCase with a Tastypi...
Physique asked 4/8, 2017 at 21:24
1
Solved
I can't seem to be able to mock the behaviour of a form when unit testing views.
My form is a simple ModelForm and resides in profiles.forms. The view is (again) a simple view that checks whether ...
Pore asked 23/4, 2017 at 12:5
1 Next >
© 2022 - 2024 — McMap. All rights reserved.