This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import unittest | |
from hamcrest import assert_that, contains_string | |
from selenium.common.exceptions import WebDriverException | |
from selenium.webdriver import Chrome | |
def wait_for_element(browser, method_name, selector, max_wait=10): | |
start_time = time.time() | |
while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from django import forms | |
from django.contrib.auth.models import User | |
from django.contrib.auth.forms import UserCreationForm | |
class UniqueUserEmailField(forms.EmailField): | |
""" | |
An EmailField which only is valid if no User has that email. | |
""" | |
def validate(self, value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Want to run your Flask tests with CSRF protections turned on, to make sure | |
# that CSRF works properly in production as well? Here's an excellent way | |
# to do it! | |
# First some imports. I'm assuming you're using Flask-WTF for CSRF protection. | |
import flask | |
from flask.testing import FlaskClient as BaseFlaskClient | |
from flask_wtf.csrf import generate_csrf | |
# Flask's assumptions about an incoming request don't quite match up with |