pymtt
 All Classes Namespaces Files Functions Variables Groups
test_TestDef.py
Go to the documentation of this file.
1 # run this via pytest
2 # export MTT_HOME=/home/wcweide/dev/mtt.forked
3 # pytest ./test_TestDef.py
4 # add the -s argument to display print lines
5 # add the -v argument to be verbose
6 # ie pytest -sv ./test_TestDef.py
7 import pytest
8 import os
9 import sys
10 import configparser
11 sys.path.append(os.path.join(os.environ['MTT_HOME'], "pylib/System"))
12 import TestDef as TD
13 
14 def setup():
15  td = TD.TestDef()
16  td.config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
17  td.config.optionxform = str
18  td.config.add_section('ENV')
19  td.config.add_section('LOG')
20  return td
21 
23  td = setup()
24  td.config.add_section('Reporter:IUDatabase')
25  print("--->sections:", td.config.sections())
26  assert td.config.sections() is not None
27  sections = ['Reporter:*']
28  print("--->to skip:", sections)
29  expsections = td.expandWildCards(sections)
30  assert 'Reporter:IUDatabase' in expsections
31  print("--->expanded:", expsections)
32 
34  td = setup()
35  td.config.add_section('Reporter:IUDatabase')
36  print("--->sections:", td.config.sections())
37  assert td.config.sections() is not None
38  sections = ['*IUDatabase']
39  print("--->to skip:", sections)
40  expsections = td.expandWildCards(sections)
41  assert 'Reporter:IUDatabase' in expsections
42  print("--->expanded:", expsections)
43 
45  td = setup()
46  td.config.add_section('Reporter:IUDatabase')
47  print("--->sections:", td.config.sections())
48  assert td.config.sections() is not None
49  sections = ['Report*UDatabase']
50  print("--->to skip:", sections)
51  expsections = td.expandWildCards(sections)
52  assert 'Reporter:IUDatabase' in expsections
53  print("--->expanded:", expsections)
54 
56  td = setup()
57  td.config.add_section('Reporter:IUDatabase')
58  td.config.add_section('Reporter:TextFile')
59  td.config.add_section('Reporter:JSONFile')
60  print("--->sections:", td.config.sections())
61  assert td.config.sections() is not None
62  sections = ['Report*UDatabase']
63  print("--->to skip:", sections)
64  expsections = td.expandWildCards(sections)
65  assert 'Reporter:IUDatabase' in expsections
66  print("--->expanded:", expsections)
67 
69  td = setup()
70  td.config.add_section('Reporter:IUDatabase')
71  td.config.add_section('Reporter:TextFile')
72  td.config.add_section('Reporter:JSONFile')
73  print("--->sections:", td.config.sections())
74  assert td.config.sections() is not None
75  sections = ['Report*']
76  print("--->to skip:", sections)
77  expsections = td.expandWildCards(sections)
78  assert 'Reporter:IUDatabase' in expsections and 'Reporter:TextFile' in expsections and 'Reporter:JSONFile' in expsections
79  print("--->expanded:", expsections)
80 
82  td = setup()
83  td.config.add_section('Reporter:XMLFile')
84  td.config.add_section('Reporter:TextFile')
85  td.config.add_section('Reporter:JSONFile')
86  print("--->sections:", td.config.sections())
87  assert td.config.sections() is not None
88  sections = ['*File']
89  print("--->to skip:", sections)
90  expsections = td.expandWildCards(sections)
91  assert 'Reporter:XMLFile' in expsections and 'Reporter:TextFile' in expsections and 'Reporter:JSONFile' in expsections
92  print("--->expanded:", expsections)
93 
95  td = setup()
96  td.config.add_section('Reporter:XMLFile')
97  td.config.add_section('Reporter:TextFile')
98  td.config.add_section('Reporter:JSONFile')
99  print("--->sections:", td.config.sections())
100  assert td.config.sections() is not None
101  sections = ['Rep*File']
102  print("--->to skip:", sections)
103  expsections = td.expandWildCards(sections)
104  assert 'Reporter:XMLFile' in expsections and 'Reporter:TextFile' in expsections and 'Reporter:JSONFile' in expsections
105  print("--->expanded:", expsections)
106 
108  td = setup()
109  td.config.add_section('Reporter:XMLFile')
110  td.config.add_section('Reporter:TextFile')
111  td.config.add_section('Reporter:JSONFile')
112  print("--->sections:", td.config.sections())
113  assert td.config.sections() is not None
114  sections = ['*porter*File']
115  print("--->to skip:", sections)
116  expsections = td.expandWildCards(sections)
117  assert 'Reporter:XMLFile' in expsections and 'Reporter:TextFile' in expsections and 'Reporter:JSONFile' in expsections
118  print("--->expanded:", expsections)
119 
121  td = setup()
122  td.config.add_section('Reporter:XMLFile')
123  td.config.add_section('Reporter:TextFile')
124  td.config.add_section('Reporter:JSONFile')
125  print("--->sections:", td.config.sections())
126  assert td.config.sections() is not None
127  sections = ['*Reporter:TextFile']
128  print("--->to skip:", sections)
129  expsections = td.expandWildCards(sections)
130  assert 'Reporter:TextFile' in expsections
131  print("--->expanded:", expsections)
132 
134  td = setup()
135  td.config.add_section('Reporter:XMLFile')
136  td.config.add_section('Reporter:TextFile')
137  td.config.add_section('Reporter:JSONFile')
138  print("--->sections:", td.config.sections())
139  assert td.config.sections() is not None
140  sections = ['Reporter:TextFile*']
141  print("--->to skip:", sections)
142  expsections = td.expandWildCards(sections)
143  assert 'Reporter:TextFile' in expsections
144  print("--->expanded:", expsections)
145 
146 # this fails
147 #def test_expandWildCardsMultipleStarsInARow():
148 # td = setup()
149 # td.config.add_section('Reporter:TextFile')
150 # print("--->sections:", td.config.sections())
151 # assert td.config.sections() is not None
152 # sections = ['Report****File']
153 # print("--->to skip:", sections)
154 # expsections = td.expandWildCards(sections)
155 # assert 'Reporter:TextFile' in expsections
156 # print("--->expanded:", expsections)
157 
159  td = setup()
160  td.config.add_section('Reporter:TextFile')
161  print("--->sections:", td.config.sections())
162  assert td.config.sections() is not None
163  sections = ['Report*:*ex*File']
164  print("--->to skip:", sections)
165  expsections = td.expandWildCards(sections)
166  assert 'Reporter:TextFile' in expsections
167  print("--->expanded:", expsections)
168 
170  td = setup()
171  td.config.add_section('Reporter:TextFile')
172  print("--->sections:", td.config.sections())
173  assert td.config.sections() is not None
174  sections = ['Reporter*:*Text*File']
175  print("--->to skip:", sections)
176  expsections = td.expandWildCards(sections)
177  assert 'Reporter:TextFile' in expsections
178  print("--->expanded:", expsections)
179 
def test_expandWildCardsAtBeginningMultiple
Definition: test_TestDef.py:81
def test_expandWildCardsAtEndMultiple
Definition: test_TestDef.py:68
def test_expandWildCardsInMiddleMultiple
Definition: test_TestDef.py:94
def test_expandWildCardsMultipleStarsInARowNoGaps
def test_expandWildCardsMultipleStarsInARow
def test_expandWildCardsMultipleStars
def test_expandWildCardsAtEnd
Definition: test_TestDef.py:22
def test_expandWildCardsInMiddle
Definition: test_TestDef.py:44
def test_expandWildCardsStarsAtEnd
def test_expandWildCardsAtBeginning
Definition: test_TestDef.py:33
def test_expandWildCardsInBigList
Definition: test_TestDef.py:55
def test_expandWildCardsStarsAtBeginning