Skip to content

Commit

Permalink
Exclude test method capabilities from HTML report and improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Aug 18, 2015
1 parent 8509385 commit 436598b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pytest_selenium/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import copy

import pytest
from selenium.webdriver.support.event_firing_webdriver import \
EventFiringWebDriver
Expand All @@ -16,7 +18,8 @@ def start_driver(item, capabilities):
raise pytest.UsageError('--driver must be specified')
# retrieve driver from appropriate method based on the value of --driver
driver = globals().get(
'{0}_driver'.format(options.driver.lower()))(item, capabilities)
'{0}_driver'.format(options.driver.lower()))(
item, copy.deepcopy(capabilities))
if options.event_listener is not None:
# import the specified event listener and wrap the driver instance
mod_name, class_name = options.event_listener.rsplit('.', 1)
Expand Down
19 changes: 11 additions & 8 deletions pytest_selenium/pytest_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@


@pytest.fixture(autouse=True)
def environment(request, base_url, capabilities):
"""Provide environment details to pytest-html report"""
def _environment(request, base_url, capabilities):
"""Provide additional environment details to pytest-html report"""
config = request.config
if hasattr(config, '_html'):
# add environment details to the pytest-html plugin if possible
config._html.environment.append({
'Base URL': base_url,
'Capabilities': capabilities,
'Driver': config.option.driver})
environment = config._html.environment
environment.extend([
('Base URL', base_url),
('Driver', config.option.driver)])
# add capabilities to environment
environment.extend([('Capability', '{0}: {1}'.format(
k, v)) for k, v in capabilities.items()])
if config.option.driver == 'Remote':
config._html.environment.append({
'Server': 'http://{0.host}:{0.port}'.format(config.option)})
environment.append(
('Server', 'http://{0.host}:{0.port}'.format(config.option)))


@pytest.fixture(scope='session')
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
packages=['pytest_selenium', 'pytest_selenium.cloud'],
install_requires=[
'pytest>=2.6.4',
'pytest-html>=1.5',
'pytest-variables',
'selenium>=2.26.0',
'requests'],
Expand Down

0 comments on commit 436598b

Please sign in to comment.