view tests/test-dirs.py @ 52153:a81d2cafdbcc stable

tests: stabilize `test-extdiff.t` on macOS The recent change in the extdiff extension to take into account whether the GUI is accessible in d1b54c152673 started triggering this. I was able to run the test cleanly without this change at the console, but somewhere along the line, I read that the CI runner isn't able to access the GUI when not run as the root user. This is causing CI failures, so we conditionalize these tests out where `DISPLAY` is set to a non empty value to force `procutil.isgui()` to be True, when it in fact doesn't have GUI access.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 01 Nov 2024 16:22:40 -0400
parents 6000f5b25c9b
children
line wrap: on
line source

import unittest

import silenttestrunner

from mercurial import pathutil


class dirstests(unittest.TestCase):
    def testdirs(self):
        for case, want in [
            (b'a/a/a', [b'a', b'a/a', b'']),
            (b'alpha/beta/gamma', [b'', b'alpha', b'alpha/beta']),
        ]:
            d = pathutil.dirs([])
            d.addpath(case)
            self.assertEqual(sorted(d), sorted(want))

    def testinvalid(self):
        with self.assertRaises(ValueError):
            d = pathutil.dirs([])
            d.addpath(b'a//b')


if __name__ == '__main__':
    silenttestrunner.main(__name__)