##// END OF EJS Templates
pycompat: custom implementation of urllib.parse.quote()...
pycompat: custom implementation of urllib.parse.quote() urllib.parse.quote() accepts either str or bytes and returns str. There exists a urllib.parse.quote_from_bytes() which only accepts bytes. We should probably use that to retain strong typing and avoid surprises. In addition, since nearly all strings in Mercurial are bytes, we probably don't want quote() returning unicode. So, this patch implements a custom quote() that only accepts bytes and returns bytes. The quoted URL should only contain URL safe characters which is a strict subset of ASCII. So `.encode('ascii', 'strict')` should be safe.

File last commit:

r28736:403b0a7a default
r31400:fb1f7033 default
Show More
silenttestrunner.py
24 lines | 734 B | text/x-python | PythonLexer
/ tests / silenttestrunner.py
Robert Stanca
py3: use print_function in silenttestrunner.py
r28730 from __future__ import absolute_import, print_function
Robert Stanca
tests: lexicographical imports in silenttestrunner.py
r28736 import os
import sys
Robert Stanca
py3: use absolute_import in silenttestrunner.py
r28729 import unittest
Idan Kamara
tests: add a test runner utility that prints nothing when all tests pass...
r18665
def main(modulename):
'''run the tests found in module, printing nothing when all tests pass'''
module = sys.modules[modulename]
suite = unittest.defaultTestLoader.loadTestsFromModule(module)
results = unittest.TestResult()
suite.run(results)
if results.errors or results.failures:
for tc, exc in results.errors:
Robert Stanca
py3: use print_function in silenttestrunner.py
r28730 print('ERROR:', tc)
print()
Idan Kamara
tests: add a test runner utility that prints nothing when all tests pass...
r18665 sys.stdout.write(exc)
for tc, exc in results.failures:
Robert Stanca
py3: use print_function in silenttestrunner.py
r28730 print('FAIL:', tc)
print()
Idan Kamara
tests: add a test runner utility that prints nothing when all tests pass...
r18665 sys.stdout.write(exc)
sys.exit(1)
Augie Fackler
silenttestrunner: add environment variable to make tests noisy again...
r23308
if os.environ.get('SILENT_BE_NOISY'):
main = unittest.main