Repository navigation
Expand file tree
/
Copy pathconftest.py
More file actions
51 lines (44 loc) · 1.47 KB
/
Copy pathconftest.py
File metadata and controls
51 lines (44 loc) · 1.47 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
51
# content of conftest.py
import pytest
import sys
import PQ9Client
import os
import PQ9TestSuite
from pytest_testconfig import config as testConfig
def pytest_configure(config):
global destinationAddress
if (config.getoption("--system") != None):
destinationAddress = config.getoption("--system")
config.option.htmlpath = destinationAddress + 'TestReport.html'
else:
destinationAddress = config.getoption("--destination")
config.option.htmlpath = 'TestReport.html'
def pytest_ignore_collect(path, config):
global destinationAddress
if (config.getoption("--system") != None):
return PQ9TestSuite.isTest(destinationAddress, os.path.basename(path))
else:
return False
def pytest_addoption(parser):
parser.addoption(
"--destination", action="store", help="subsystem address", dest="destination",
)
parser.addoption(
"--system", action="store", help="subsystem", dest="system",
)
@pytest.fixture
def BinaryFiles():
return testConfig['PQ9EGSE']['BinaryFiles']
@pytest.fixture
def destination(request):
global destinationAddress
return destinationAddress
@pytest.fixture(scope="session") #only 'make' this object once per session.
def pq9_connection():
pq9client = PQ9Client.PQ9Client(
testConfig['PQ9EGSE']['server'],
testConfig['PQ9EGSE']['port'],
float(testConfig['PQ9EGSE']['timeout']))
pq9client.connect()
yield pq9client
pq9client.close()