call site 10 for path.local.chdir
test/testing/test_collect.py - line 216
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
   def test_custom_python_collection_from_conftest():
       o = tmpdir.ensure('customconfigtest', dir=1)
       o.ensure('conftest.py').write("""if 1:
           import py
           class MyFunction(py.test.collect.Function):
               pass
           class Directory(py.test.collect.Directory):
               def filefilter(self, fspath):
                   return fspath.check(basestarts='check_', ext='.py')
           class myfuncmixin: 
               Function = MyFunction
               def funcnamefilter(self, name): 
                   return name.startswith('check_') 
   
           class Module(myfuncmixin, py.test.collect.Module):
               def classnamefilter(self, name): 
                   return name.startswith('CustomTestClass') 
           class Instance(myfuncmixin, py.test.collect.Instance):
               pass 
           """)
       checkfile = o.ensure('somedir', 'check_something.py')
       checkfile.write("""if 1:
           def check_func():
               assert 42 == 42
           class CustomTestClass:
               def check_method(self):
                   assert 23 == 23
           """)
   
       for x in (o, checkfile, checkfile.dirpath()): 
           config = py.test.config._reparse([x])
           #print "checking that %s returns custom items" % (x,) 
           col = config._getcollector(x)
           assert len(list(col._tryiter(py.test.collect.Item))) == 2 
           #assert items[1].__class__.__name__ == 'MyFunction'
   
       # test that running a session works from the directories
       old = o.chdir() 
       try: 
           config = py.test.config._reparse([]) 
           out = py.std.cStringIO.StringIO()
           session = config._getsessionclass()(config, out) 
           session.main() 
           l = session.getitemoutcomepairs(Passed) 
           assert len(l) == 2
       finally: 
->         old.chdir() 
   
       # test that running the file directly works 
       config = py.test.config._reparse([str(checkfile)]) 
       out = py.std.cStringIO.StringIO()
       session = config._getsessionclass()(config, out) 
       session.main() 
       l = session.getitemoutcomepairs(Passed) 
       assert len(l) == 2