14def ROOT6WorkAroundEnabled(id=None):
15 """
16 Helper function to easily exclude ROOT6 work-arounds for testing.
17
18 >>> os.environ['ROOT6_WORK_AROUND'] = 'all'
19 >>> ROOT6WorkAroundEnabled()
20 True
21 >>> os.environ['ROOT6_WORK_AROUND'] = 'none'
22 >>> ROOT6WorkAroundEnabled('JIRA-XYZ')
23 False
24 >>> os.environ['ROOT6_WORK_AROUND'] = 'JIRA-X'
25 >>> ROOT6WorkAroundEnabled('JIRA-X')
26 True
27 >>> ROOT6WorkAroundEnabled('JIRA-Y')
28 True
29 >>> os.environ['ROOT6_WORK_AROUND'] = 'JIRA-X,-JIRA-Y'
30 >>> ROOT6WorkAroundEnabled('JIRA-X')
31 True
32 >>> ROOT6WorkAroundEnabled('JIRA-Y')
33 False
34 >>> os.environ['ROOT6_WORK_AROUND'] = '-JIRA-Y'
35 >>> ROOT6WorkAroundEnabled('JIRA-X')
36 True
37 >>> ROOT6WorkAroundEnabled('JIRA-Y')
38 False
39 """
40 enabled = os.environ.get("ROOT6_WORK_AROUND", "all").lower()
41 if enabled == "all":
42 return True
43 if enabled in ("none", "no", "off", "false", "0"):
44 return False
45 if id is None:
46 return True
47 enabled = set(map(str.strip, enabled.split(",")))
48 disabled = set([e[1:] for e in enabled if e.startswith("-")])
49 id = id.lower()
50
51 return id in enabled or id not in disabled