1- from tests import testmodels
1+ from tests import testmodels_postgres as testmodels
22from tortoise .contrib import test
3- from tortoise .exceptions import IntegrityError
3+ from tortoise .exceptions import IntegrityError , OperationalError
44
55
6- class TestArrayFields (test .TestCase ):
7- @test .requireCapability (dialect = "postgres" )
6+ @test .requireCapability (dialect = "postgres" )
7+ class TestArrayFields (test .IsolatedTestCase ):
8+ tortoise_test_modules = ["tests.testmodels_postgres" ]
9+
10+ async def _setUpDB (self ) -> None :
11+ try :
12+ await super ()._setUpDB ()
13+ except OperationalError :
14+ raise test .SkipTest ("Works only with PostgreSQL" )
15+
816 async def test_empty (self ):
917 with self .assertRaises (IntegrityError ):
1018 await testmodels .ArrayFields .create ()
1119
12- @test .requireCapability (dialect = "postgres" )
1320 async def test_create (self ):
1421 obj0 = await testmodels .ArrayFields .create (array = [0 ])
1522 obj = await testmodels .ArrayFields .get (id = obj0 .id )
@@ -19,21 +26,18 @@ async def test_create(self):
1926 obj2 = await testmodels .ArrayFields .get (id = obj .id )
2027 self .assertEqual (obj , obj2 )
2128
22- @test .requireCapability (dialect = "postgres" )
2329 async def test_update (self ):
2430 obj0 = await testmodels .ArrayFields .create (array = [0 ])
2531 await testmodels .ArrayFields .filter (id = obj0 .id ).update (array = [1 ])
2632 obj = await testmodels .ArrayFields .get (id = obj0 .id )
2733 self .assertEqual (obj .array , [1 ])
2834 self .assertIs (obj .array_null , None )
2935
30- @test .requireCapability (dialect = "postgres" )
3136 async def test_values (self ):
3237 obj0 = await testmodels .ArrayFields .create (array = [0 ])
3338 values = await testmodels .ArrayFields .get (id = obj0 .id ).values ("array" )
3439 self .assertEqual (values ["array" ], [0 ])
3540
36- @test .requireCapability (dialect = "postgres" )
3741 async def test_values_list (self ):
3842 obj0 = await testmodels .ArrayFields .create (array = [0 ])
3943 values = await testmodels .ArrayFields .get (id = obj0 .id ).values_list ("array" , flat = True )
0 commit comments