Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
Continuing my investigation I got the a following which does not work but 
should:
from django.contrib.auth.models import User
from django.test import TransactionTestCase
from django.db import transaction

class FooTest(TransactionTestCase):
def test_bar(self):
with transaction.atomic():
with transaction.atomic():
u = User.objects.create_user(username="abc", 
password="pass")
print("created user: {}".format(u.username))

The crash of "SAVEPOINT does not exist" occurs when exiting inner `
*transaction.atomic*' block.


On Tuesday, May 12, 2020 at 10:35:31 AM UTC+3, Uri Kogan wrote:
>
> The documentation states that "you cannot test that a block of code is 
> executing within a transaction" while I am looking to "test a block of code 
> that has a transaction".
> In any case, the issue here is that "transaction.atomic" does not work 
> when nested while it should clearly work.
>
> On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>>
>> Probably you need to use TransactionTestCase, which is the parent of 
>> TestCase instead: 
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
>> That page also mentions a specific problem when using transaction on 
>> TestCase:
>> ```
>> A consequence of this, however, is that some database behaviors cannot be 
>> tested within a Django TestCase class. For instance, you cannot test 
>> that a block of code is executing within a transaction, as is required when 
>> using select_for_update() 
>> .
>>  
>> In those cases, you should use TransactionTestCase.
>> 111
>>
>> On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:
>>
>>> That not that simple in my case because. I'll show what I mean:
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>> from rolepermissions.roles import assign_role
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> u = User.objects.create_user(username="abc", password="pass")
>>> assign_role(u, "role_admin")
>>> retrieve_and_analyze_view_using_u_credentials()
>>>
>>> I am testing that my permission routines work by creating a user, 
>>> assigning permissions to the user, retrieving the view and analyzing it. 
>>> That "assign_role" call of django-role-permissions uses 
>>> "transaction.atomic". Which, of course, I would not want to change, as this 
>>> is an external library.
>>>
>>> So I can't really remove usages of "transaction.atomic"
>>>
>>>
>>>
>>> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:

 When testing django apps, my unit test usually accesses the django app 
 via django test client: 
 https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
 .
 Django test client simulates http access, so my Django tests always run 
 my Django code starting from Django views. 
 Even though there must be many django app code that has 
 `transaction.atomic` inside it, I never need to add `transaction.atomic` 
 in 
 my unit test code.
 If I need to simulate initial state by having some data inserted to 
 database, I did that either using factoryboy or django ORM framework, but 
 I 
 see no point to add `transaction.atomic` to that data initialization code.

 On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> While this can be done in my code, there are libraries that the 
> project use that have "transaction.atomic" in them. For example, pretty 
> popular django-role-permissions.
> From what I see in the documentation, there should be no problem to 
> use transactions within transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> I don't think the subclass of TestCase need to use 
>> transaction.atomic. Why can't you just remove the transaction.atomic? 
>>
>> Regards, 
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
>> menulis:
>>
>>> Hello,
>>>
>>> I am using TestCase and trying to create an object during test.
>>> There is a log activated on MySQL server, so I see all the queries 
>>> being executed there.
>>>
>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking 
>>> that the transaction is already started. The problem is that there is 
>>> no 
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>> the 
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic() 
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> 

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
The documentation states that "you cannot test that a block of code is 
executing within a transaction" while I am looking to "test a block of code 
that has a transaction".
In any case, the issue here is that "transaction.atomic" does not work when 
nested while it should clearly work.

On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>
> Probably you need to use TransactionTestCase, which is the parent of 
> TestCase instead: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
> That page also mentions a specific problem when using transaction on 
> TestCase:
> ```
> A consequence of this, however, is that some database behaviors cannot be 
> tested within a Django TestCase class. For instance, you cannot test that 
> a block of code is executing within a transaction, as is required when 
> using select_for_update() 
> .
>  
> In those cases, you should use TransactionTestCase.
> 111
>
> On Tue, May 12, 2020 at 1:59 PM Uri Kogan > 
> wrote:
>
>> That not that simple in my case because. I'll show what I mean:
>>
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>> from rolepermissions.roles import assign_role
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> u = User.objects.create_user(username="abc", password="pass")
>> assign_role(u, "role_admin")
>> retrieve_and_analyze_view_using_u_credentials()
>>
>> I am testing that my permission routines work by creating a user, 
>> assigning permissions to the user, retrieving the view and analyzing it. 
>> That "assign_role" call of django-role-permissions uses 
>> "transaction.atomic". Which, of course, I would not want to change, as this 
>> is an external library.
>>
>> So I can't really remove usages of "transaction.atomic"
>>
>>
>>
>> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>>>
>>> When testing django apps, my unit test usually accesses the django app 
>>> via django test client: 
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>>> .
>>> Django test client simulates http access, so my Django tests always run 
>>> my Django code starting from Django views. 
>>> Even though there must be many django app code that has 
>>> `transaction.atomic` inside it, I never need to add `transaction.atomic` in 
>>> my unit test code.
>>> If I need to simulate initial state by having some data inserted to 
>>> database, I did that either using factoryboy or django ORM framework, but I 
>>> see no point to add `transaction.atomic` to that data initialization code.
>>>
>>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>>
 While this can be done in my code, there are libraries that the project 
 use that have "transaction.atomic" in them. For example, pretty popular 
 django-role-permissions.
 From what I see in the documentation, there should be no problem to use 
 transactions within transactions in TestCase.

 On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>
> I don't think the subclass of TestCase need to use transaction.atomic. 
> Why can't you just remove the transaction.atomic? 
>
> Regards, 
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>
> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
> menulis:
>
>> Hello,
>>
>> I am using TestCase and trying to create an object during test.
>> There is a log activated on MySQL server, so I see all the queries 
>> being executed there.
>>
>> This "transaction.atomic" sets a SAVEPOINT in the database thinking 
>> that the transaction is already started. The problem is that there is no 
>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>> the 
>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>
>> The following states that TestCase "tests within two nested atomic() 
>> blocks", so it should execute "TRANSACTION START"
>>
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>
>> 
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>>
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> with transaction.atomic():
>> user = User.objects.create_user(username="abc", 
>> password="pass")
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google 
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to django...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
Probably you need to use TransactionTestCase, which is the parent of
TestCase instead:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
That page also mentions a specific problem when using transaction on
TestCase:
```
A consequence of this, however, is that some database behaviors cannot be
tested within a Django TestCase class. For instance, you cannot test that a
block of code is executing within a transaction, as is required when using
select_for_update()
.
In those cases, you should use TransactionTestCase.
111

On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:

> That not that simple in my case because. I'll show what I mean:
>
> from django.contrib.auth.models import User
> from django.test import TestCase
> from rolepermissions.roles import assign_role
>
> class FooTest(TestCase):
> def test_bar(self):
> u = User.objects.create_user(username="abc", password="pass")
> assign_role(u, "role_admin")
> retrieve_and_analyze_view_using_u_credentials()
>
> I am testing that my permission routines work by creating a user,
> assigning permissions to the user, retrieving the view and analyzing it.
> That "assign_role" call of django-role-permissions uses
> "transaction.atomic". Which, of course, I would not want to change, as this
> is an external library.
>
> So I can't really remove usages of "transaction.atomic"
>
>
>
> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>>
>> When testing django apps, my unit test usually accesses the django app
>> via django test client:
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>> .
>> Django test client simulates http access, so my Django tests always run
>> my Django code starting from Django views.
>> Even though there must be many django app code that has
>> `transaction.atomic` inside it, I never need to add `transaction.atomic` in
>> my unit test code.
>> If I need to simulate initial state by having some data inserted to
>> database, I did that either using factoryboy or django ORM framework, but I
>> see no point to add `transaction.atomic` to that data initialization code.
>>
>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>
>>> While this can be done in my code, there are libraries that the project
>>> use that have "transaction.atomic" in them. For example, pretty popular
>>> django-role-permissions.
>>> From what I see in the documentation, there should be no problem to use
>>> transactions within transactions in TestCase.
>>>
>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:

 I don't think the subclass of TestCase need to use transaction.atomic.
 Why can't you just remove the transaction.atomic?

 Regards,

 Aldian Fazrihady
 http://aldianfazrihady.com

 Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
 menulis:

> Hello,
>
> I am using TestCase and trying to create an object during test.
> There is a log activated on MySQL server, so I see all the queries
> being executed there.
>
> This "transaction.atomic" sets a SAVEPOINT in the database thinking
> that the transaction is already started. The problem is that there is no
> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
> the
> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>
> The following states that TestCase "tests within two nested atomic()
> blocks", so it should execute "TRANSACTION START"
>
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>
>
> from django.contrib.auth.models import User
> from django.test import TestCase
>
>
> class FooTest(TestCase):
> def test_bar(self):
> with transaction.atomic():
> user = User.objects.create_user(username="abc",
> password="pass")
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
> 
> .
>
 --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
That not that simple in my case because. I'll show what I mean:

from django.contrib.auth.models import User
from django.test import TestCase
from rolepermissions.roles import assign_role

class FooTest(TestCase):
def test_bar(self):
u = User.objects.create_user(username="abc", password="pass")
assign_role(u, "role_admin")
retrieve_and_analyze_view_using_u_credentials()

I am testing that my permission routines work by creating a user, assigning 
permissions to the user, retrieving the view and analyzing it. That "
assign_role" call of django-role-permissions uses "transaction.atomic". 
Which, of course, I would not want to change, as this is an external 
library.

So I can't really remove usages of "transaction.atomic"



On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>
> When testing django apps, my unit test usually accesses the django app via 
> django test client: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
> .
> Django test client simulates http access, so my Django tests always run my 
> Django code starting from Django views. 
> Even though there must be many django app code that has 
> `transaction.atomic` inside it, I never need to add `transaction.atomic` in 
> my unit test code.
> If I need to simulate initial state by having some data inserted to 
> database, I did that either using factoryboy or django ORM framework, but I 
> see no point to add `transaction.atomic` to that data initialization code.
>
> On Tue, May 12, 2020 at 12:39 PM Uri Kogan > 
> wrote:
>
>> While this can be done in my code, there are libraries that the project 
>> use that have "transaction.atomic" in them. For example, pretty popular 
>> django-role-permissions.
>> From what I see in the documentation, there should be no problem to use 
>> transactions within transactions in TestCase.
>>
>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>
>>> I don't think the subclass of TestCase need to use transaction.atomic. 
>>> Why can't you just remove the transaction.atomic? 
>>>
>>> Regards, 
>>>
>>> Aldian Fazrihady
>>> http://aldianfazrihady.com
>>>
>>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
>>> menulis:
>>>
 Hello,

 I am using TestCase and trying to create an object during test.
 There is a log activated on MySQL server, so I see all the queries 
 being executed there.

 This "transaction.atomic" sets a SAVEPOINT in the database thinking 
 that the transaction is already started. The problem is that there is no 
 "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
 the 
 whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"

 The following states that TestCase "tests within two nested atomic() 
 blocks", so it should execute "TRANSACTION START"

 https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase

 
 from django.contrib.auth.models import User
 from django.test import TestCase


 class FooTest(TestCase):
 def test_bar(self):
 with transaction.atomic():
 user = User.objects.create_user(username="abc", 
 password="pass")


 -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
  
 
 .

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91984522-1535-4f37-8fb8-ae76c7095298%40googlegroups.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
When testing django apps, my unit test usually accesses the django app via
django test client:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client.
Django test client simulates http access, so my Django tests always run my
Django code starting from Django views.
Even though there must be many django app code that has
`transaction.atomic` inside it, I never need to add `transaction.atomic` in
my unit test code.
If I need to simulate initial state by having some data inserted to
database, I did that either using factoryboy or django ORM framework, but I
see no point to add `transaction.atomic` to that data initialization code.

On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> While this can be done in my code, there are libraries that the project
> use that have "transaction.atomic" in them. For example, pretty popular
> django-role-permissions.
> From what I see in the documentation, there should be no problem to use
> transactions within transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> I don't think the subclass of TestCase need to use transaction.atomic.
>> Why can't you just remove the transaction.atomic?
>>
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
>> menulis:
>>
>>> Hello,
>>>
>>> I am using TestCase and trying to create an object during test.
>>> There is a log activated on MySQL server, so I see all the queries being
>>> executed there.
>>>
>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking that
>>> the transaction is already started. The problem is that there is no
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic()
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>>
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> with transaction.atomic():
>>> user = User.objects.create_user(username="abc",
>>> password="pass")
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAYO3N3E7Jrds9sqmnfKOUFHwtdf%3DXMra2WZ3WCiDiJfEw%40mail.gmail.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Uri Kogan
While this can be done in my code, there are libraries that the project use 
that have "transaction.atomic" in them. For example, pretty popular 
django-role-permissions.
>From what I see in the documentation, there should be no problem to use 
transactions within transactions in TestCase.

On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>
> I don't think the subclass of TestCase need to use transaction.atomic. Why 
> can't you just remove the transaction.atomic? 
>
> Regards, 
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>
> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  > menulis:
>
>> Hello,
>>
>> I am using TestCase and trying to create an object during test.
>> There is a log activated on MySQL server, so I see all the queries being 
>> executed there.
>>
>> This "transaction.atomic" sets a SAVEPOINT in the database thinking that 
>> the transaction is already started. The problem is that there is no 
>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the 
>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>
>> The following states that TestCase "tests within two nested atomic() 
>> blocks", so it should execute "TRANSACTION START"
>>
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>
>> 
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>>
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> with transaction.atomic():
>> user = User.objects.create_user(username="abc", 
>> password="pass")
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Aldian Fazrihady
I don't think the subclass of TestCase need to use transaction.atomic. Why
can't you just remove the transaction.atomic?

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  menulis:

> Hello,
>
> I am using TestCase and trying to create an object during test.
> There is a log activated on MySQL server, so I see all the queries being
> executed there.
>
> This "transaction.atomic" sets a SAVEPOINT in the database thinking that
> the transaction is already started. The problem is that there is no
> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>
> The following states that TestCase "tests within two nested atomic()
> blocks", so it should execute "TRANSACTION START"
>
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>
>
> from django.contrib.auth.models import User
> from django.test import TestCase
>
>
> class FooTest(TestCase):
> def test_bar(self):
> with transaction.atomic():
> user = User.objects.create_user(username="abc",
> password="pass")
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAZi_aRZcppf1xZ6XLF4FGJULq3pL7pnoi33HainJa0JgQ%40mail.gmail.com.