neorg / neorg / tests / test_verutils.py

from itertools import product

from neorg.verutils import NEOrgVersion


def test_version_str():
    for verstr in ['0.0.1', '0.0.2.dev0', '1.2.3.dev45']:
        assert str(NEOrgVersion(verstr)) == verstr


def test_version_parse():
    for (i, j, k, l) in product(*([range(10)] * 4)):
        if l == 0:
            NEOrgVersion('{0}.{1}.{2}'.format(i, j, k))
        NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(i, j, k, l))


def test_version_compare():
    for (i, j, k, l) in product(*([range(1, 10)] * 4)):
        if l == 0:
            assert (
                NEOrgVersion('{0}.{1}.{2}'.format(i, j, k)) ==
                NEOrgVersion('{0}.{1}.{2}'.format(i, j, k)))
            for ijk0 in [(i - 1, j, k),
                         (i, j - 1, k),
                         (i, j, k - 1)]:
                assert (
                    NEOrgVersion('{0}.{1}.{2}'.format(i, j, k)) >
                    NEOrgVersion('{0}.{1}.{2}'.format(*ijk0)))
        assert (
            NEOrgVersion('{0}.{1}.{2}'.format(i, j, k)) >
            NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(i, j, k, l)))
        assert (
            NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(i, j, k, l)) ==
            NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(i, j, k, l)))
        for ijkl0 in [(i - 1, j, k, l),
                      (i, j - 1, k, l),
                      (i, j, k - 1, l),
                      (i, j, k, l - 1)]:
            assert (
                NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(i, j, k, l)) >
                NEOrgVersion('{0}.{1}.{2}.dev{3}'.format(*ijkl0)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.