Skip to main content

pytest plugin for Firefox Accounts

Project description

pytest-fxa is a plugin for pytest that provides test accounts for Firefox Accounts.

License PyPI Travis Issues Updates Python 3


You will need the following prerequisites in order to use pytest-fxa:

  • Python 2.7, 3.6, PyPy, or PyPy3


To install pytest-fxa:

$ pip install pytest-fxa

Creating a test Firefox Account

To create a Firefox Account for testing, include the fxa_account fixture name in your test method signature. This is a tuple with named properties for the test account’s email and password. The following example shows how this could be used with Selenium to sign into a website that uses Firefox Accounts for authentication:

def test_my_fxa_site(fxa_account, selenium):
    selenium.find_element(By.ID, 'email').send_keys(
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()

The test account will be automatically destroyed when it’s no longer needed.

Specifying an environment

By default all accounts will be created on the ‘stage’ environment. You can set the FXA_ENV environment variable to target ‘production’ or ‘stable’.

If you need to override the environment for a subset of tests, or run tests against multiple environments, you can use the fxa_env marker:

def test_production(fxa_account):
    selenium.find_element(By.ID, 'email').send_keys(
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()

@pytest.mark.fxa_env('stage', 'stable')
def test_stage(fxa_account):
    selenium.find_element(By.ID, 'email').send_keys(
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()

Alternatively, you can override the fxa_urls fixture for full control of the URLs for your environment:

def fxa_urls():
    return {
        'authentication': '',
        'oauth': '',
        'content': '',
        'profile': '',
        'token': ''}


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-fxa-1.4.0.tar.gz (7.1 kB view hashes)

Uploaded source

Built Distribution

pytest_fxa-1.4.0-py2.py3-none-any.whl (4.6 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page