Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Created June 30, 2021 15:11
Show Gist options
  • Save nietzscheson/2ede152e51bb88d5060a6a82cb53a3b1 to your computer and use it in GitHub Desktop.
Save nietzscheson/2ede152e51bb88d5060a6a82cb53a3b1 to your computer and use it in GitHub Desktop.
Override MEDIA_ROOT configuration
import graphene
import json
import tempfile
import shutil
from draphene.factory import PostFactory, UserFactory
from django.test import override_settings
from graphene_django.utils.testing import GraphQLTestCase
MEDIA_ROOT = tempfile.mkdtemp()
@override_settings(MEDIA_ROOT=MEDIA_ROOT)
class PostTestCase(GraphQLTestCase):
GRAPHQL_URL = "/graphql"
@classmethod
def tearDownClass(cls):
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
super().tearDownClass()
def test_create(self):
post = PostFactory.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment