diff options
-rw-r--r-- | conftest.py | 9 | ||||
-rw-r--r-- | tests/versioning/tests.py | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/conftest.py b/conftest.py index 2475876..53a8b88 100644 --- a/conftest.py +++ b/conftest.py @@ -61,4 +61,11 @@ def mytest_model(): @pytest.fixture(scope='function', autouse=False) def user_instance(request, admin_user): - request.cls.user = admin_user
\ No newline at end of file + request.cls.user = admin_user + + +@pytest.fixture(autouse=True) +def has_git_requirements(request, project_root): + if request.node.get_marker('has_git_requirements'): + if not os.path.exists(os.path.join(project_root, '.git', 'refs', 'heads', 'master')): + pytest.skip('skipped test as project is not a git repo') diff --git a/tests/versioning/tests.py b/tests/versioning/tests.py index fb63bbc..0878ef3 100644 --- a/tests/versioning/tests.py +++ b/tests/versioning/tests.py @@ -4,15 +4,10 @@ import os.path import pytest import subprocess -from conftest import project_root from raven.utils.compat import string_types from raven.versioning import fetch_git_sha, fetch_package_version -def has_git_requirements(project_root): - return os.path.exists(os.path.join(project_root, '.git', 'refs', 'heads', 'master')) - - # Python 2.6 does not contain subprocess.check_output def check_output(cmd, **kwargs): return subprocess.Popen( @@ -22,8 +17,7 @@ def check_output(cmd, **kwargs): ).communicate()[0] -@pytest.mark.skipif(not has_git_requirements(project_root()), - reason='unable to detect git repository') +@pytest.mark.has_git_requirements def test_fetch_git_sha(project_root): result = fetch_git_sha(project_root) assert result is not None |