This instance will be upgraded to Heptapod 0.21.0rc2 on 2021-04-16 at 11:00 UTC+2 (a few minutes of down time)

mercurialapi_test.py 843 Bytes
Newer Older
1 2 3
"""Test for compatibility with Mercurial API"""

import inspect
4 5

import pytest
6 7
from nose.tools import *

8
from tortoisehg.util import hglib, pipeui
9

10
def test_same_argspec(f, g):
11 12 13 14 15 16 17
    fa, ga = inspect.getargspec(f), inspect.getargspec(g)
    assert_equals(fa, ga,
                  '%s != %s' % (inspect.formatargspec(*fa),
                                inspect.formatargspec(*ga)))

def overridden_methods(cls):
    basemethods = inspect.getmembers(cls.__base__, inspect.ismethod)
18
    return [(basemeth, getattr(cls, name))
19
            for name, basemeth in basemethods
20
            if basemeth.__func__ is not getattr(cls, name).__func__]
21 22


23
def pytest_generate_tests(metafunc):
24
    ui = hglib.loadui()
25
    pipeui.uisetup(ui)
26 27
    if metafunc.function == test_same_argspec:
        metafunc.parametrize('f, g', overridden_methods(ui.__class__))