Changeset - cf8c3cf122a0
[Not reviewed]
default
1 1 1
Marc Abramowitz - 11 years ago 2015-04-15 23:58:12
marc@marc-abramowitz.com
tests: Make `parameterized` stuff work with both pytest and nose

- Use `nose.tools.nottest` if `nose` is available
- Use `pytest.mark.skipIf` if `pytest` is available
- Rename from `nose_parametrized` to `parameterized` since it's no longer
nose-specific
2 files changed with 20 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/__init__.py
Show inline comments
 
@@ -55,7 +55,7 @@ from nose.plugins.skip import SkipTest
 
from kallithea.lib.compat import unittest
 
from kallithea import is_windows
 
from kallithea.model.db import User
 
from kallithea.tests.nose_parametrized import parameterized
 
from kallithea.tests.parameterized import parameterized
 
from kallithea.lib.utils2 import safe_str
 

	
 

	
kallithea/tests/parameterized.py
Show inline comments
 
file renamed from kallithea/tests/nose_parametrized.py to kallithea/tests/parameterized.py
 
@@ -5,10 +5,27 @@ import logging
 
import logging.handlers
 
from functools import wraps
 

	
 
from nose.tools import nottest
 
from unittest import TestCase
 

	
 

	
 
def skip_test(func):
 
    try:
 
        from nose.tools import nottest
 
    except ImportError:
 
        pass
 
    else:
 
        func = nottest(func)
 

	
 
    try:
 
        import pytest
 
    except ImportError:
 
        pass
 
    else:
 
        func = pytest.mark.skipIf(True, func)
 

	
 
    return func
 

	
 

	
 
def _terrible_magic_get_defining_classes():
 
    """ Returns the set of parent classes of the class currently being defined.
 
        Will likely only work if called from the ``parameterized`` decorator.
 
@@ -125,7 +142,7 @@ def parameterized_expand(input):
 
            name = base_name + name_suffix
 
            new_func = parameterized_expand_helper(name, f, args)
 
            frame_locals[name] = new_func
 
        return nottest(f)
 
        return skip_test(f)
 
    return parameterized_expand_wrapper
 

	
 
parameterized.expand = parameterized_expand
0 comments (0 inline, 0 general)