diff --git a/cubicweb_s3storage/testing.py b/cubicweb_s3storage/testing.py
new file mode 100644
index 0000000000000000000000000000000000000000..1f9689d9080dca062d98f798995f6c198ed8b2ce_Y3ViaWN3ZWJfczNzdG9yYWdlL3Rlc3RpbmcucHk=
--- /dev/null
+++ b/cubicweb_s3storage/testing.py
@@ -0,0 +1,22 @@
+import boto3
+from moto import mock_s3
+
+from cubicweb_s3storage.storages import S3Storage
+
+
+class S3StorageTestMixin(object):
+
+    bucket = 'test-bucket'
+
+    def setUp(self):
+        self.s3_mock = mock_s3()
+        self.s3_mock.start()
+        resource = boto3.resource('s3', region_name='somewhere')
+        self.s3_bucket = resource.create_bucket(Bucket=self.bucket)
+        self.s3_storage = S3Storage(self.bucket)
+        super(S3StorageTestMixin, self).setUp()
+
+    def tearDown(self):
+        super(S3StorageTestMixin, self).tearDown()
+        del self.s3_storage
+        self.s3_mock.stop()
diff --git a/test/test_s3storage.py b/test/test_s3storage.py
index 635090b28a664d215c4d04fcb9d6c15dfc3d20b3_dGVzdC90ZXN0X3Mzc3RvcmFnZS5weQ==..1f9689d9080dca062d98f798995f6c198ed8b2ce_dGVzdC90ZXN0X3Mzc3RvcmFnZS5weQ== 100644
--- a/test/test_s3storage.py
+++ b/test/test_s3storage.py
@@ -10,6 +10,7 @@
 from cubicweb import Binary
 from cubicweb.server.migractions import ServerMigrationHelper
 from cubicweb_s3storage.storages import S3Storage
+from cubicweb_s3storage import testing
 
 
 def create_file(cnx, content=b'the-data'):
@@ -18,8 +19,7 @@
                              data_name=u'foo.pdf')
 
 
-class S3StorageTC(CubicWebTC):
-    bucket = 'test-bucket'
+class S3StorageTC(testing.S3StorageTestMixin, CubicWebTC):
 
     def setUp(self):
         super(S3StorageTC, self).setUp()
@@ -23,15 +23,9 @@
 
     def setUp(self):
         super(S3StorageTC, self).setUp()
-        mock = mock_s3()
-        mock.start()
-        resource = boto3.resource('s3', region_name='somewhere')
-        self.s3_bucket = resource.create_bucket(Bucket=self.bucket)
-        s3_storage = S3Storage(self.bucket)
-        storages.set_attribute_storage(self.repo, 'File', 'data', s3_storage)
-        self.s3_storage = s3_storage
-        self.s3_mock = mock
+        storages.set_attribute_storage(
+            self.repo, 'File', 'data', self.s3_storage)
 
     def tearDown(self):
         super(S3StorageTC, self).tearDown()
         storages.unset_attribute_storage(self.repo, 'File', 'data')
@@ -34,9 +28,7 @@
 
     def tearDown(self):
         super(S3StorageTC, self).tearDown()
         storages.unset_attribute_storage(self.repo, 'File', 'data')
-        del self.s3_storage
-        self.s3_mock.stop()
 
     def test_s3key_gen(self):
         with self.admin_access.client_cnx() as cnx: