Firefox Accounts的pytest插件
项目描述
pytest-fxa 是一个pytest插件,它为Firefox Accounts提供测试账户。
要求
使用pytest-fxa,您需要以下先决条件:
Python 2.7, 3.6, PyPy或PyPy3
安装
要安装pytest-fxa:
$ pip install pytest-fxa
创建一个测试Firefox账户
为了创建一个用于测试的Firefox账户,在测试方法签名中包含fxa_account fixture名称。这是一个具有命名属性的元组,用于测试账户的email和password。以下示例显示了如何使用Selenium与使用Firefox Accounts进行身份验证的网站进行登录
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()
当不再需要时,测试账户将被自动销毁。
指定环境
默认情况下,所有账户都将创建在“测试”环境中。您可以将FXA_ENV环境变量设置为“生产”或“稳定”。
如果您需要为测试子集覆盖环境,或针对多个环境运行测试,您可以使用fxa_env标记
@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()
或者,您可以使用fxa_urls固定装置来完全控制您环境的URL
@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/'}
资源
项目详情
关闭
pytest-fxa-1.4.0.tar.gz的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | b75967e74e9b2f3ffa5558421fdf61c7fff5948fc9d7e357e7147c682988ecc1 |
|
MD5 | 87962676552dc583f8dee99841a910db |
|
BLAKE2b-256 | 47959d8dd8759e7e202455312d4c70ea5f9bd8e2bb2466c75f37889123c58b59 |
关闭
pytest_fxa-1.4.0-py2.py3-none-any.whl的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | 778dfdb019f1e0af8744704fe5f7ac5c08fd5d45ff054023b0a18d5f99d737f1 |
|
MD5 | 6781ac1f5426dd82cbda3cfeb6f43a3c |
|
BLAKE2b-256 | 7f39fc1d84052e94075786fb72302a4b1f8a83b160f8d0025a55ce242803f68d |