-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconftest.py
More file actions
50 lines (38 loc) · 1.26 KB
/
conftest.py
File metadata and controls
50 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Provide some base configurations for tests."""
import phpypam
import pytest
import py.path # pyright: ignore reportMissingImports=false
import yaml
from urllib.parse import urlparse, urlunparse
TEST_CASES_PATH = py.path.local(__file__).realpath() / '..' / 'test_cases'
with open('tests/vars/server.yml') as c:
server = yaml.safe_load(c)
@pytest.fixture(scope='module')
def pi(*arg, **kwargs):
"""Create a phpypam.api object and return it.
:return: object phpypam
:rtype: phpypam.api
"""
url = kwargs.pop('url', server['url'])
app_id = kwargs.pop('app_id', server['app_id'])
username = kwargs.pop('username', server['username'])
password = kwargs.pop('password', server['password'])
ssl_verify = kwargs.pop('ssl_verify', server['ssl_verify'])
return phpypam.api(
url=url,
app_id=app_id,
username=username,
password=password,
ssl_verify=ssl_verify,
**kwargs
)
def find_all_test_cases():
"""Generate list of test cases.
:yield: generates each test case as list item
:rtype: str
"""
for c in TEST_CASES_PATH.listdir(sort=True):
c = c.basename
if c.endswith('.py'):
yield c.replace('.py', '')
TEST_CASES = list(find_all_test_cases())