pytest-fxa is a plugin for pytest that provides test accounts for Firefox Accounts.
Requirements
You will need the following prerequisites in order to use pytest-fxa:
Python 2.7, 3.6, 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
Release files for pytest-fxa 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-fxa-1.4.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_fxa-1.4.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.7 kB
Release files / pytest-fxa-1.4.0.tar.gz
| Download URL | pytest-fxa-1.4.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b75967e74e9b2f3ffa5558421fdf61c7fff5948fc9d7e357e7147c682988ecc1
|
|
BLAKE2b-256 checksum How to use checksums |
47959d8dd8759e7e202455312d4c70ea5f9bd8e2bb2466c75f37889123c58b59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
|
Release files / pytest_fxa-1.4.0-py2.py3-none-any.whl
| Download URL | pytest_fxa-1.4.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
778dfdb019f1e0af8744704fe5f7ac5c08fd5d45ff054023b0a18d5f99d737f1
|
|
BLAKE2b-256 checksum How to use checksums |
7f39fc1d84052e94075786fb72302a4b1f8a83b160f8d0025a55ce242803f68d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
|