Skip to main content

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

License PyPI https://img.shields.io/badge/code%20style-black-000000.svg Issues Dependabot

Requirements

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

  • Python 2.7, 3.6, 3.7, PyPy, or PyPy3

Installation

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.get('https://example.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    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:

@pytest.mark.fxa_env('production')
def test_production(fxa_account):
    selenium.get('https://example.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    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.get('https://elpmaxe.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    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:

@pytest.fixture
def fxa_urls():
    return {
        'authentication': 'https://api-accounts.stage.mozaws.net/v1',
        'oauth': 'https://oauth.stage.mozaws.net/v1',
        'content': 'https://accounts.stage.mozaws.net/',
        'profile': 'https://profile.stage.mozaws.net/v1',
        'token': 'https://token.stage.mozaws.net/'}

Resources

Metadata

Release files for pytest-fxa-mte 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-fxa-mte 1.8.0
File Size Uploaded
pytest_fxa_mte-1.8.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-fxa-mte 1.8.0
File Interpreter ABI Platform
pytest_fxa_mte-1.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / pytest_fxa_mte-1.8.0.tar.gz

Download URL pytest_fxa_mte-1.8.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
582357d8689be13747d877e5115f13660698175b724f858f4d4abd1db2b9f822
BLAKE2b-256 checksum
How to use checksums
da592f19bdef06060ea9d6b202817897bb44b8c6cffa81a74ee5afd92d410be8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / pytest_fxa_mte-1.8.0-py3-none-any.whl

Download URL pytest_fxa_mte-1.8.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d6c3bc7bf0efaa037931afabd4596f99ddd49c0cb4b0ffb4f4f08e9fb748410
BLAKE2b-256 checksum
How to use checksums
e1e885ea1709af33d603cea79ca8e650b7d49fed81da36a7f7451d4503fc24c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page