Skip to content

Commit ea661a2

Browse files
committed
Handle cleanup of proxy zip file between test runs
1 parent f2d2fdd commit ea661a2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import optparse
44
import pytest
55
from seleniumbase.core import log_helper
6+
from seleniumbase.core import proxy_helper
67
from seleniumbase.fixtures import constants
78

89

@@ -84,6 +85,7 @@ def pytest_addoption(parser):
8485
default=None,
8586
help="""Designates the proxy server:port to use.
8687
Format: servername:port. OR
88+
username:password@servername:port OR
8789
A dict key from proxy_list.PROXY_LIST
8890
Default: None.""")
8991
parser.addoption('--headless', action="store_true",
@@ -138,11 +140,12 @@ def pytest_configure(config):
138140
if with_testing_base:
139141
log_path = config.getoption('log_path')
140142
log_helper.log_folder_setup(log_path)
143+
proxy_helper.remove_proxy_zip_if_present()
141144

142145

143146
def pytest_unconfigure():
144-
""" This runs after all tests have completed with pytest """
145-
pass
147+
""" This runs after all tests have completed with pytest. """
148+
proxy_helper.remove_proxy_zip_if_present()
146149

147150

148151
def pytest_runtest_setup():

seleniumbase/plugins/selenium_plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from nose.plugins import Plugin
77
from pyvirtualdisplay import Display
8+
from seleniumbase.core import proxy_helper
89
from seleniumbase.fixtures import constants
910

1011

@@ -62,6 +63,7 @@ def options(self, parser, env):
6263
default=None,
6364
help="""Designates the proxy server:port to use.
6465
Format: servername:port. OR
66+
username:password@servername:port OR
6567
A dict key from proxy_list.PROXY_LIST
6668
Default: None.""")
6769
parser.add_option(
@@ -116,6 +118,7 @@ def configure(self, options, conf):
116118
self.enabled = True # Used if test class inherits BaseCase
117119
self.options = options
118120
self.headless_active = False # Default setting
121+
proxy_helper.remove_proxy_zip_if_present()
119122

120123
def beforeTest(self, test):
121124
test.test.browser = self.options.browser
@@ -142,6 +145,10 @@ def beforeTest(self, test):
142145
self.driver = None
143146
test.test.driver = self.driver
144147

148+
def finalize(self, result):
149+
""" This runs after all tests have completed with nosetests. """
150+
proxy_helper.remove_proxy_zip_if_present()
151+
145152
def afterTest(self, test):
146153
try:
147154
# If the browser window is still open, close it now.

0 commit comments

Comments
 (0)