import os

from django.forms import Form
from django.test import TestCase

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget


class RecaptchaTestForm(Form):
    recaptcha = ReCaptchaField(widget=ReCaptchaWidget())


class TestRecaptchaForm(TestCase):
    def setUp(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'

    def test_dummy_validation(self):
        form = RecaptchaTestForm({})
        self.assertTrue(form.is_valid())

    def tearDown(self):
        del os.environ['RECAPTCHA_DISABLE']

import os

from django.forms import Form
from django.test import TestCase

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget


class RecaptchaTestForm(Form):
    recaptcha = ReCaptchaField(widget=ReCaptchaWidget())


class TestRecaptchaForm(TestCase):
    def setUp(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'

    def test_dummy_validation(self):
        form = RecaptchaTestForm({})
        self.assertTrue(form.is_valid())

    def test_dummy_error(self):
        del os.environ['RECAPTCHA_DISABLE']
        form = RecaptchaTestForm({})
        self.assertFalse(form.is_valid())

    def tearDown(self):
        del os.environ['RECAPTCHA_DISABLE']

Check possible exception with wrong key data
Check possible exception with wrong key data

  import os
  
  from django.forms import Form
  from django.test import TestCase
  
  from snowpenguin.django.recaptcha2.fields import ReCaptchaField
  from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget
  
  
  class RecaptchaTestForm(Form):
      recaptcha = ReCaptchaField(widget=ReCaptchaWidget())
  
  
  class TestRecaptchaForm(TestCase):
      def setUp(self):
          os.environ['RECAPTCHA_DISABLE'] = 'True'
  
      def test_dummy_validation(self):
          form = RecaptchaTestForm({})
          self.assertTrue(form.is_valid())
  
+     def test_dummy_error(self):
+         del os.environ['RECAPTCHA_DISABLE']
+         form = RecaptchaTestForm({})
+         self.assertFalse(form.is_valid())
+ 
      def tearDown(self):
          del os.environ['RECAPTCHA_DISABLE']
  
Check possible exception with wrong key data
## Code Before:
import os

from django.forms import Form
from django.test import TestCase

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget


class RecaptchaTestForm(Form):
    recaptcha = ReCaptchaField(widget=ReCaptchaWidget())


class TestRecaptchaForm(TestCase):
    def setUp(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'

    def test_dummy_validation(self):
        form = RecaptchaTestForm({})
        self.assertTrue(form.is_valid())

    def tearDown(self):
        del os.environ['RECAPTCHA_DISABLE']

## Instruction:
Check possible exception with wrong key data
## Code After:
import os

from django.forms import Form
from django.test import TestCase

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget


class RecaptchaTestForm(Form):
    recaptcha = ReCaptchaField(widget=ReCaptchaWidget())


class TestRecaptchaForm(TestCase):
    def setUp(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'

    def test_dummy_validation(self):
        form = RecaptchaTestForm({})
        self.assertTrue(form.is_valid())

    def test_dummy_error(self):
        del os.environ['RECAPTCHA_DISABLE']
        form = RecaptchaTestForm({})
        self.assertFalse(form.is_valid())

    def tearDown(self):
        del os.environ['RECAPTCHA_DISABLE']
