tests/test-dirs.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 11 Sep 2020 09:55:08 -0700
changeset 45449 814c7430f828
parent 43523 c21aca51b392
child 48021 627cd8f33db0
permissions -rw-r--r--
tests: make emacs test less strict It was failing like this for me: ``` @@ -2,7 +2,7 @@ $ emacs -q -no-site-file -batch -l $TESTDIR/../contrib/hg-test-mode.el \ > -f ert-run-tests-batch-and-exit Running 1 tests (*) (glob) - passed 1/1 hg-test-mode--compilation-mode-support + passed 1/1 hg-test-mode--compilation-mode-support (0.045732 sec) - Ran 1 tests, 1 results as expected (*) (glob) + Ran 1 tests, 1 results as expected, 0 unexpected (2020-09-11 16:49:56+0000, 0.046034 sec) ``` Differential Revision: https://phab.mercurial-scm.org/D9017

from __future__ import absolute_import

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__)