File: noxfile.py

package info (click to toggle)
mercurial-extension-utils 1.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: python: 1,385; makefile: 7; sh: 4
file content (64 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import nox
import pathlib

###########################################################################
# WARNING
#
# to handle 2.7 one must be careful to use virtualenv<20.22.0,
# otherwise
#   „nox RuntimeError: failed to find interpreter for Builtin discover of python_spec='python2.7'”
# errors appear.
#
# Easiest way:
#    pipx install nox
#    pipx inject nox 'virtualenv<20.22.0'
###########################################################################


# Tested versions. Python → list of mercurials
TESTED = {
    '2.7': [
        '3.4', '3.8', '4.1', '4.9', '5.0', '5.5', '5.9',
    ],
    '3.8': [
        '5.0', '5.9',
    ],
    '3.10': [
        '5.5', '5.9', '6.1', '6.4', '6.7', '6.8',
    ],
    '3.12': [
        '6.5', '6.7', '6.8',
    ]
}

###########################################################################

nox.options.envdir = pathlib.Path.home() / ".nox_venvs" / "mercurial_exts"
nox.options.reuse_venv = True

###########################################################################

def _hgver_to_clause(ver):
    ver_items = ver.split('.')
    result = "Mercurial>={0}.{1},<{0}.{2}".format(
        ver_items[0], ver_items[1], int(ver_items[1]) + 1)
    return result


@nox.session
@nox.parametrize('python,hgver', [
    (pyver, hgver)
    for pyver in TESTED
    for hgver in TESTED[pyver]
])
def tests(session, hgver):
    if not session.python.startswith('2.') and hgver.startswith('5.'):
        session.env['HGPYTHON3'] = '1'
    session.env['HGRCPATH'] = '/dev/null'

    if session.python in ['3.4']:
        session.install('doctest')

    session.install(_hgver_to_clause(hgver))
    session.install('.')
    session.run('python', '-m', 'unittest', 'discover', 'tests')