Skip to content

Commit 88de946

Browse files
committed
Add "self.env" for handling test environments
1 parent 3149464 commit 88de946

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, *args, **kwargs):
7070
super(BaseCase, self).__init__(*args, **kwargs)
7171
self.driver = None
7272
self.environment = None
73+
self.env = None # Add a shortened version of self.environment
7374
self.__last_url_of_delayed_assert = "data:,"
7475
self.__last_page_load_url = "data:,"
7576
self.__page_check_count = 0
@@ -2754,6 +2755,8 @@ def setUp(self):
27542755
test_id = "%s.%s.%s" % (self.__class__.__module__,
27552756
self.__class__.__name__,
27562757
self._testMethodName)
2758+
self.environment = pytest.config.option.environment
2759+
self.env = self.environment # Add a shortened version
27572760
self.with_selenium = pytest.config.option.with_selenium
27582761
self.headless = pytest.config.option.headless
27592762
self.headless_active = False

seleniumbase/fixtures/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
class Environment:
7+
# Usage Example => "--env=qa" => Then access value in tests with "self.env"
78
QA = "qa"
89
STAGING = "staging"
910
PRODUCTION = "production"

seleniumbase/plugins/base_plugin.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@
1717

1818
class Base(Plugin):
1919
"""
20-
The base_plugin includes the following variables:
21-
self.options.env -- the environment for the tests to use (--env=ENV)
22-
self.options.data -- any extra data to pass to the tests (--data=DATA)
23-
self.options.log_path -- the directory in which the log files
24-
are saved (--log_path=LOG_PATH)
20+
The base_plugin includes the following variables for nosetest runs:
21+
self.env -- The environment for the tests to use (Usage: --env=ENV)
22+
self.data -- Any extra data to pass to the tests (Usage: --data=DATA)
23+
self.log_path -- The directory where log files get saved to
24+
(Usage: --log_path=LOG_PATH)
25+
self.report -- The option to create a fancy report after tests complete
26+
(Usage: --report)
27+
self.show_report -- If self.report is turned on, then the report will
28+
display immediately after tests complete their run.
29+
Only use this when running tests locally, as this will
30+
pause the test run until the report window is closed.
31+
(Usage: --show_report)
2532
"""
2633
name = 'testing_base' # Usage: --with-testing_base
2734

@@ -90,6 +97,7 @@ def beforeTest(self, test):
9097
if not os.path.exists(test_logpath):
9198
os.makedirs(test_logpath)
9299
test.test.environment = self.options.environment
100+
test.test.env = self.options.environment # Add a shortened version
93101
test.test.data = self.options.data
94102
test.test.args = self.options
95103
self.test_count += 1

0 commit comments

Comments
 (0)