Пример #1
0
def _get_xunit_func(obj, name):
    """Return the attribute from the given object to be used as a setup/teardown
    xunit-style function, but only if not marked as a fixture to
    avoid calling it twice.
    """
    meth = getattr(obj, name, None)
    if fixtures.getfixturemarker(meth) is None:
        return meth
Пример #2
0
 def istestfunction(self, obj, name):
     if self.funcnamefilter(name) or self.isnosetest(obj):
         if isinstance(obj, staticmethod):
             # static methods need to be unwrapped
             obj = safe_getattr(obj, "__func__", False)
         return (
             safe_getattr(obj, "__call__", False)
             and fixtures.getfixturemarker(obj) is None
         )
     else:
         return False
Пример #3
0
 def istestfunction(self, obj, name):
     if self.funcnamefilter(name) or self.isnosetest(obj):
         if isinstance(obj, staticmethod):
             # static methods need to be unwrapped
             obj = safe_getattr(obj, "__func__", False)
             if obj is False:
                 # Python 2.6 wraps in a different way that we won't try to handle
                 msg = "cannot collect static method %r because it is not a function"
                 self.warn(code="C2", message=msg % name)
                 return False
         return (safe_getattr(obj, "__call__", False)
                 and fixtures.getfixturemarker(obj) is None)
     else:
         return False
Пример #4
0
 def istestfunction(self, obj, name):
     if self.funcnamefilter(name) or self.isnosetest(obj):
         if isinstance(obj, staticmethod):
             # static methods need to be unwrapped
             obj = safe_getattr(obj, "__func__", False)
             if obj is False:
                 # Python 2.6 wraps in a different way that we won't try to handle
                 msg = "cannot collect static method %r because it is not a function"
                 self.warn(code="C2", message=msg % name)
                 return False
         return (
             safe_getattr(obj, "__call__", False)
             and fixtures.getfixturemarker(obj) is None
         )
     else:
         return False
Пример #5
0
def test_pytestconfig_is_session_scoped() -> None:
    from _pytest.fixtures import pytestconfig

    marker = getfixturemarker(pytestconfig)
    assert marker is not None
    assert marker.scope == "session"