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
class LogoutMixin: | |
def logout_params(self, next_page): | |
# Backend should provide this | |
return { | |
'logout_uri': next_page | |
} | |
def logout_baseurl(self): | |
# Backend should provide this | |
return '/logout' |
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 logging | |
import time | |
from django.conf import settings | |
from django.db import connection | |
THRESHOLD = getattr(settings, 'SLOW_REQUEST_THRESHOLD', 1.0) | |
LOG_SQL = getattr(settings, 'SLOW_REQUEST_LOG_SQL', False) | |
LOG = logging.getLogger(__name__) |
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
from nlm_selenium.seleniumtest import SeleniumTestCase | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions | |
import pytest | |
from nlm_selenium.configuration import SeleniumSettings | |
@pytest.fixture(scope='module') | |
def selenium_settings(pytestconfig): | |
s = SeleniumSettings(pytestconfig) |
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 os | |
import multiprocessing | |
import subprocess | |
import sys | |
import traceback | |
def make_unreadable_file(path): | |
os.chmod(path, 0o000) | |
if sys.platform == "win32": | |
# Once we drop PY2 we can use `os.getlogin()` instead. |
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
[pytest] | |
baseurl = https://ned.nih.gov | |
browser = chrome |
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
""" | |
Adapted from the page-objects Python package addressing two perceived shortfalls: | |
- Lack of an easy way to get at the locator for a field, for instance for waits. | |
- Extra calls to driver.find_element() without any caching. | |
The API of this module is mostly backwards compatible with page-objects, with the following differences: | |
- The `root_uri` kwarg or PageObject is deprecated in favor of `base_url`, but root_uri is still supported. | |
- The behavior where setting the attribute sends keys seems to obscure the selenium bindings for selenium, | |
and are too magical, so they are removed. | |
- The factory methods at end are removed, because I never used it with factory methods |
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
## Example settings wodge for standard configuration | |
LOGGING_CONFIG = 'nlm.occs.logging.configure_logging' | |
# The above compiles to our current "standard" wodge, except: | |
# - all "local" apps become installed apps | |
# - the level for "local" apps becomes automatically either 'DEBUG' if settings.DEBUG else 'INFO' | |
LOGGING = { | |
'version': 1, |
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
def a_decorator_that_takes_arguments(fubar): | |
def inner_decorator(func): | |
nonlocal fubar | |
func.thing = fubar | |
return func | |
return inner_decorator | |
class ThingUsingDecorator(object): | |
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
#!/usr/bin/env python | |
import argparse | |
import os | |
import sys | |
from django.core.management import call_command | |
from tests.runtests import setup, teardown | |
def django_testshell(verbosity, test_labels): |