Skip to content

Commit

Permalink
add skip_skins marker
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Moro committed Jun 13, 2017
1 parent 17745e7 commit 8a10529
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pypom_navigation/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
from .parametrizer import Parametrizer


def skip_skins(skins):
"""
Decorator to mark tests to be skipped for the given skin ids.
ie. @skip_skins(['skin1', 'skin2'])
:return pytest.mark:
"""
return pytest.mark.skip_skins(skins)


@pytest.fixture(scope='session')
def skin():
""" This fixture provides the skin associated with the application
Expand Down
45 changes: 45 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,51 @@ def test_generated_skip_skins(skin_base_url, skin,
assert result.ret == 0


@pytest.mark.parametrize('credentials_file', ['credentials.yml',
'credentials.json'])
def test_skip_by_skin_names_import(testdir, credentials_file):
""" Skip by skin names
"""
import os

# create a temporary pytest test module
testdir.makepyfile("""
import pytest
from pypom_navigation.plugin import skip_skins
@pytest.fixture(scope='session', params=['skin1', 'skin2'])
def skin(request):
return request.param
@skip_skins(['skin1'])
def test_generated_skip_skins(skin_base_url, skin,
variables):
if skin == 'skin1':
assert 0
elif skin == 'skin2':
assert skin_base_url == 'https://skin2-coolsite.com'
assert variables['skins'][skin]\
['base_url'] == skin_base_url
""")

# run pytest with the following cmd args
result = testdir.runpytest(
'--variables={0}'.format(os.path.join(os.path.dirname(__file__),
credentials_file)),
'-v'
)

# fnmatch_lines does an assertion internally
result_text = result.stdout.str()
assert 'test_generated_skip_skins[skin1] SKIPPED' in result_text
assert 'test_generated_skip_skins[skin2] PASSED' in result_text

# make sure that that we get a '0' exit code for the testsuite
assert result.ret == 0


def test_base_page():
from mock import patch
from mock import Mock
Expand Down

0 comments on commit 8a10529

Please sign in to comment.