view tests/test-dirs.py @ 51996:625cf9621551

tests: add a module that can perform the equivalent of `SIGKILL` on any OS I started with this being Windows specific, but let's push all of the decision making into this function so that it can just be called by the tests. The tradeoff is that this is very specific to sending `SIGKILL`- since `signal.SIGKILL` doesn't exist on Windows, the desired signal can't be passed from the caller. Maybe there's a way, but let's wait until there's a need. We don't use `killdaemons.py` unconditionally because it starts with a more graceful `SIGTERM` on posix.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 12 Oct 2024 16:06:37 -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__)