Skip to content

Commit 0dbd4b8

Browse files
authored
Merge pull request #269 from seleniumbase/mostly-pytest-improvements
Mostly replacing a pytest deprecated call with a new one
2 parents 14e24a3 + 13e0262 commit 0dbd4b8

File tree

4 files changed

+60
-34
lines changed

4 files changed

+60
-34
lines changed

seleniumbase/console_scripts/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def main():
189189
show_basic_usage()
190190
show_mkdir_usage()
191191
elif command == "download":
192-
if len(command_args) >= 1:
192+
if len(command_args) >= 1 and command_args[0].lower() == "server":
193193
download_selenium_server.main(force_download=True)
194194
else:
195195
show_basic_usage()

seleniumbase/fixtures/base_case.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def test_anything(self):
3131
import unittest
3232
import uuid
3333
from bs4 import BeautifulSoup
34+
from seleniumbase import config as sb_config
3435
from seleniumbase.common import decorators
3536
from seleniumbase.config import settings
3637
from seleniumbase.core.application_manager import ApplicationManager
@@ -2727,7 +2728,7 @@ def setUp(self):
27272728
self.is_pytest = None
27282729
try:
27292730
# This raises an exception if the test is not coming from pytest
2730-
self.is_pytest = pytest.config.option.is_pytest
2731+
self.is_pytest = sb_config.is_pytest
27312732
except Exception:
27322733
# Not using pytest (probably nosetests)
27332734
self.is_pytest = False
@@ -2736,34 +2737,33 @@ def setUp(self):
27362737
test_id = "%s.%s.%s" % (self.__class__.__module__,
27372738
self.__class__.__name__,
27382739
self._testMethodName)
2739-
self.environment = pytest.config.option.environment
2740+
self.browser = sb_config.browser
2741+
self.data = sb_config.data
2742+
self.demo_mode = sb_config.demo_mode
2743+
self.demo_sleep = sb_config.demo_sleep
2744+
self.highlights = sb_config.highlights
2745+
self.environment = sb_config.environment
27402746
self.env = self.environment # Add a shortened version
2741-
self.with_selenium = pytest.config.option.with_selenium
2742-
self.headless = pytest.config.option.headless
2747+
self.with_selenium = sb_config.with_selenium # Should be True
2748+
self.headless = sb_config.headless
27432749
self.headless_active = False
2744-
self.with_testing_base = pytest.config.option.with_testing_base
2745-
self.with_db_reporting = pytest.config.option.with_db_reporting
2746-
self.with_s3_logging = pytest.config.option.with_s3_logging
2747-
self.with_screen_shots = pytest.config.option.with_screen_shots
2748-
self.with_basic_test_info = (
2749-
pytest.config.option.with_basic_test_info)
2750-
self.with_page_source = pytest.config.option.with_page_source
2751-
self.servername = pytest.config.option.servername
2752-
self.port = pytest.config.option.port
2753-
self.proxy_string = pytest.config.option.proxy_string
2754-
self.cap_file = pytest.config.option.cap_file
2755-
self.database_env = pytest.config.option.database_env
2756-
self.log_path = pytest.config.option.log_path
2757-
self.browser = pytest.config.option.browser
2758-
self.data = pytest.config.option.data
2759-
self.demo_mode = pytest.config.option.demo_mode
2760-
self.demo_sleep = pytest.config.option.demo_sleep
2761-
self.highlights = pytest.config.option.highlights
2762-
self.message_duration = pytest.config.option.message_duration
2763-
self.js_checking_on = pytest.config.option.js_checking_on
2764-
self.ad_block_on = pytest.config.option.ad_block_on
2765-
self.verify_delay = pytest.config.option.verify_delay
2766-
self.timeout_multiplier = pytest.config.option.timeout_multiplier
2750+
self.log_path = sb_config.log_path
2751+
self.with_testing_base = sb_config.with_testing_base
2752+
self.with_basic_test_info = sb_config.with_basic_test_info
2753+
self.with_screen_shots = sb_config.with_screen_shots
2754+
self.with_page_source = sb_config.with_page_source
2755+
self.with_db_reporting = sb_config.with_db_reporting
2756+
self.with_s3_logging = sb_config.with_s3_logging
2757+
self.servername = sb_config.servername
2758+
self.port = sb_config.port
2759+
self.proxy_string = sb_config.proxy_string
2760+
self.cap_file = sb_config.cap_file
2761+
self.database_env = sb_config.database_env
2762+
self.message_duration = sb_config.message_duration
2763+
self.js_checking_on = sb_config.js_checking_on
2764+
self.ad_block_on = sb_config.ad_block_on
2765+
self.verify_delay = sb_config.verify_delay
2766+
self.timeout_multiplier = sb_config.timeout_multiplier
27672767
self.use_grid = False
27682768
if self.servername != "localhost":
27692769
# Use Selenium Grid (Use --server=127.0.0.1 for localhost Grid)
@@ -2898,7 +2898,7 @@ def tearDown(self):
28982898
self.is_pytest = None
28992899
try:
29002900
# This raises an exception if the test is not coming from pytest
2901-
self.is_pytest = pytest.config.option.is_pytest
2901+
self.is_pytest = sb_config.is_pytest
29022902
except Exception:
29032903
# Not using pytest (probably nosetests)
29042904
self.is_pytest = False

seleniumbase/plugins/pytest_plugin.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import optparse
44
import pytest
5+
from seleniumbase import config as sb_config
56
from seleniumbase.core import log_helper
67
from seleniumbase.core import proxy_helper
78
from seleniumbase.fixtures import constants
@@ -149,10 +150,35 @@ def pytest_addoption(parser):
149150

150151
def pytest_configure(config):
151152
""" This runs after command line options have been parsed """
152-
with_testing_base = config.getoption('with_testing_base')
153-
if with_testing_base:
154-
log_path = config.getoption('log_path')
155-
log_helper.log_folder_setup(log_path)
153+
sb_config.is_pytest = True
154+
sb_config.browser = config.getoption('browser')
155+
sb_config.data = config.getoption('data')
156+
sb_config.environment = config.getoption('environment')
157+
sb_config.with_selenium = config.getoption('with_selenium')
158+
sb_config.headless = config.getoption('headless')
159+
sb_config.with_testing_base = config.getoption('with_testing_base')
160+
sb_config.with_db_reporting = config.getoption('with_db_reporting')
161+
sb_config.with_s3_logging = config.getoption('with_s3_logging')
162+
sb_config.with_screen_shots = config.getoption('with_screen_shots')
163+
sb_config.with_basic_test_info = config.getoption('with_basic_test_info')
164+
sb_config.with_page_source = config.getoption('with_page_source')
165+
sb_config.servername = config.getoption('servername')
166+
sb_config.port = config.getoption('port')
167+
sb_config.proxy_string = config.getoption('proxy_string')
168+
sb_config.cap_file = config.getoption('cap_file')
169+
sb_config.database_env = config.getoption('database_env')
170+
sb_config.log_path = config.getoption('log_path')
171+
sb_config.demo_mode = config.getoption('demo_mode')
172+
sb_config.demo_sleep = config.getoption('demo_sleep')
173+
sb_config.highlights = config.getoption('highlights')
174+
sb_config.message_duration = config.getoption('message_duration')
175+
sb_config.js_checking_on = config.getoption('js_checking_on')
176+
sb_config.ad_block_on = config.getoption('ad_block_on')
177+
sb_config.verify_delay = config.getoption('verify_delay')
178+
sb_config.timeout_multiplier = config.getoption('timeout_multiplier')
179+
180+
if sb_config.with_testing_base:
181+
log_helper.log_folder_setup(sb_config.log_path)
156182
proxy_helper.remove_proxy_zip_if_present()
157183

158184

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.18.0',
20+
version='1.18.1',
2121
description='Reliable Browser Automation & Testing Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)