Skip to content

Commit f04cce3

Browse files
committed
Merge pull request #16 from mdmintz/tidy-up-pytest-config
Tidy up pytest config
2 parents 51299a1 + 1ebc59d commit f04cce3

File tree

3 files changed

+13
-51
lines changed

3 files changed

+13
-51
lines changed

Diff for: conftest.py

+11-49
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
""" This is the pytest configuration file """
22

3+
import optparse
34
import os
45
import shutil
56
import time
6-
from optparse import SUPPRESS_HELP
77
from seleniumbase.config import settings
88
from seleniumbase.fixtures import constants
99

@@ -43,7 +43,7 @@ def pytest_addoption(parser):
4343
dest='database_env',
4444
choices=('prod', 'qa', 'test'),
4545
default='test',
46-
help=SUPPRESS_HELP)
46+
help=optparse.SUPPRESS_HELP)
4747
parser.addoption('--with-s3_logging', action="store_true",
4848
dest='with_s3_logging',
4949
default=False,
@@ -77,55 +77,12 @@ def pytest_addoption(parser):
7777

7878

7979
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 """
11881
log_folder_setup(config)
11982

12083

121-
def pytest_unconfigure():
122-
pytest_config = '.pytest_config'
123-
if os.path.isfile(pytest_config):
124-
os.remove(pytest_config)
125-
126-
12784
def log_folder_setup(config):
128-
# Handle Logging
85+
""" Handle Logging """
12986
with_testing_base = config.getoption('with_testing_base')
13087
if with_testing_base:
13188
log_path = config.getoption('log_path')
@@ -144,11 +101,16 @@ def log_folder_setup(config):
144101
shutil.rmtree(archived_logs)
145102

146103

104+
def pytest_unconfigure():
105+
""" This runs after all tests have completed with pytest """
106+
pass
107+
108+
147109
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 """
149111
pass
150112

151113

152114
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 """
154116
pass

Diff for: integrations/docker/docker_setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.1.26',
11+
version='1.1.27',
1212
author='Michael Mintz',
1313
author_email='@mintzworld',
1414
maintainer='Michael Mintz',

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='seleniumbase',
9-
version='1.1.26',
9+
version='1.1.27',
1010
url='https://github.com/mdmintz/SeleniumBase',
1111
author='Michael Mintz',
1212
author_email='@mintzworld',

0 commit comments

Comments
 (0)