File: __init__.py

package info (click to toggle)
python-exchangelib 5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,084 kB
  • sloc: python: 25,351; sh: 6; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import logging
import os
import random
import unittest.util
from unittest import TestLoader, TestSuite

from exchangelib.util import PrettyXmlHandler


class RandomTestSuite(TestSuite):
    def __iter__(self):
        tests = list(super().__iter__())
        random.shuffle(tests)
        return iter(tests)


# Execute test classes in random order
TestLoader.suiteClass = RandomTestSuite
# Execute test methods in random order within each test class
TestLoader.sortTestMethodsUsing = lambda _, x, y: random.choice((1, -1))
# Make sure we're also random in multiprocess test runners
random.seed()

# Always show full repr() output for object instances in unittest error messages
unittest.util._MAX_LENGTH = 2000

if os.environ.get("DEBUG", "").lower() in ("1", "yes", "true"):
    logging.basicConfig(level=logging.DEBUG, handlers=[PrettyXmlHandler()])
    logging.getLogger("requests").setLevel(level=logging.INFO)
    logging.getLogger("requests_oauthlib").setLevel(level=logging.INFO)
    logging.getLogger("urllib3").setLevel(level=logging.INFO)
else:
    logging.basicConfig(level=logging.CRITICAL)