1
1
""" This is the pytest configuration file """
2
2
3
+ import optparse
3
4
import os
4
5
import shutil
5
6
import time
6
- from optparse import SUPPRESS_HELP
7
7
from seleniumbase .config import settings
8
8
from seleniumbase .fixtures import constants
9
9
@@ -43,7 +43,7 @@ def pytest_addoption(parser):
43
43
dest = 'database_env' ,
44
44
choices = ('prod' , 'qa' , 'test' ),
45
45
default = 'test' ,
46
- help = SUPPRESS_HELP )
46
+ help = optparse . SUPPRESS_HELP )
47
47
parser .addoption ('--with-s3_logging' , action = "store_true" ,
48
48
dest = 'with_s3_logging' ,
49
49
default = False ,
@@ -77,55 +77,12 @@ def pytest_addoption(parser):
77
77
78
78
79
79
def pytest_configure (config ):
80
- with_selenium = config .getoption ('with_selenium' )
81
- with_testing_base = config .getoption ('with_testing_base' )
82
- with_db_reporting = config .getoption ('with_db_reporting' )
83
- with_s3_logging = config .getoption ('with_s3_logging' )
84
- with_screen_shots = config .getoption ('with_screen_shots' )
85
- with_basic_test_info = config .getoption ('with_basic_test_info' )
86
- with_page_source = config .getoption ('with_page_source' )
87
- database_env = config .getoption ('database_env' )
88
- browser = config .getoption ('browser' )
89
- log_path = config .getoption ('log_path' )
90
- headless = config .getoption ('headless' )
91
- demo_mode = config .getoption ('demo_mode' )
92
- demo_sleep = ''
93
- data = ''
94
- if config .getoption ('demo_sleep' ) is not None :
95
- demo_sleep = config .getoption ('demo_sleep' )
96
- if config .getoption ('data' ) is not None :
97
- data = config .getoption ('data' )
98
- if config .getoption ('database_env' ) is not None :
99
- database_env = config .getoption ('database_env' )
100
- # Create a temporary config file while tests are running
101
- pytest_config = '.pytest_config'
102
- config_file = open (pytest_config , 'w+' )
103
- config_file .write ("with_selenium:::%s\n " % with_selenium )
104
- config_file .write ("browser:::%s\n " % browser )
105
- config_file .write ("data:::%s\n " % data )
106
- config_file .write ("with_testing_base:::%s\n " % with_testing_base )
107
- config_file .write ("with_db_reporting:::%s\n " % with_db_reporting )
108
- config_file .write ("with_s3_logging:::%s\n " % with_s3_logging )
109
- config_file .write ("with_screen_shots:::%s\n " % with_screen_shots )
110
- config_file .write ("with_basic_test_info:::%s\n " % with_basic_test_info )
111
- config_file .write ("with_page_source:::%s\n " % with_page_source )
112
- config_file .write ("database_env:::%s\n " % database_env )
113
- config_file .write ("log_path:::%s\n " % log_path )
114
- config_file .write ("headless:::%s\n " % headless )
115
- config_file .write ("demo_mode:::%s\n " % demo_mode )
116
- config_file .write ("demo_sleep:::%s\n " % demo_sleep )
117
- config_file .close ()
80
+ """ This runs after command line options have been parsed """
118
81
log_folder_setup (config )
119
82
120
83
121
- def pytest_unconfigure ():
122
- pytest_config = '.pytest_config'
123
- if os .path .isfile (pytest_config ):
124
- os .remove (pytest_config )
125
-
126
-
127
84
def log_folder_setup (config ):
128
- # Handle Logging
85
+ """ Handle Logging """
129
86
with_testing_base = config .getoption ('with_testing_base' )
130
87
if with_testing_base :
131
88
log_path = config .getoption ('log_path' )
@@ -144,11 +101,16 @@ def log_folder_setup(config):
144
101
shutil .rmtree (archived_logs )
145
102
146
103
104
+ def pytest_unconfigure ():
105
+ """ This runs after all tests have completed with pytest """
106
+ pass
107
+
108
+
147
109
def pytest_runtest_setup ():
148
- # A placeholder for a method that runs before every test with pytest
110
+ """ This runs before every test with pytest """
149
111
pass
150
112
151
113
152
114
def pytest_runtest_teardown ():
153
- # A placeholder for a method that runs after every test with pytest
115
+ """ This runs after every test with pytest """
154
116
pass
0 commit comments