File: test_version.py

package info (click to toggle)
jupyter-server 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,844 kB
  • sloc: python: 12,331; makefile: 175; javascript: 72
file content (48 lines) | stat: -rw-r--r-- 1,128 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
import re
import pytest

from jupyter_server import __version__


pep440re = re.compile(r'^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$')

def raise_on_bad_version(version):
    if not pep440re.match(version):
        raise ValueError("Versions String does apparently not match Pep 440 specification, "
                        "which might lead to sdist and wheel being seen as 2 different release. "
                        "E.g: do not use dots for beta/alpha/rc markers.")

# --------- Meta test to test the versioning tests -------------

@pytest.mark.parametrize(
    'version',
    [
        '4.1.0.b1',
        '4.1.b1',
        '4.2',
        'X.y.z',
        '1.2.3.dev1.post2',
    ]
)
def test_invalid_pep440_versions(version):
    with pytest.raises(ValueError):
        raise_on_bad_version(version)


@pytest.mark.parametrize(
    'version',
    [
        '4.1.1',
        '4.2.1b3',
    ]
)
def test_valid_pep440_versions(version):
    assert raise_on_bad_version(version) is None


# --------- Test current version --------------
def test_current_version():
    raise_on_bad_version(__version__)