view tests/test-encoding-func.py @ 36689:b394778b1a50 stable

test-subrepo: glob away an unstable hash This is the instability mentioned at the beginning of the series. I don't like hiding it, but I don't want to sit on a fix for a user reported problem while trying to figure this out. The instability seems related to the cset with a .hgsub with a remote URL. (There's very little existing remote URL subrepo testing.)
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 03 Mar 2018 22:29:24 -0500
parents 6c119dbfd0c0
children 57b0c7221dba
line wrap: on
line source

from __future__ import absolute_import

import unittest

from mercurial import (
    encoding,
)

class IsasciistrTest(unittest.TestCase):
    asciistrs = [
        b'a',
        b'ab',
        b'abc',
        b'abcd',
        b'abcde',
        b'abcdefghi',
        b'abcd\0fghi',
    ]

    def testascii(self):
        for s in self.asciistrs:
            self.assertTrue(encoding.isasciistr(s))

    def testnonasciichar(self):
        for s in self.asciistrs:
            for i in range(len(s)):
                t = bytearray(s)
                t[i] |= 0x80
                self.assertFalse(encoding.isasciistr(bytes(t)))

class LocalEncodingTest(unittest.TestCase):
    def testasciifastpath(self):
        s = b'\0' * 100
        self.assertTrue(s is encoding.tolocal(s))
        self.assertTrue(s is encoding.fromlocal(s))

class Utf8bEncodingTest(unittest.TestCase):
    def testasciifastpath(self):
        s = b'\0' * 100
        self.assertTrue(s is encoding.toutf8b(s))
        self.assertTrue(s is encoding.fromutf8b(s))

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