This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest fixture finder
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: purcell Nosy List: bcsaller, purcell
Priority: normal Keywords: patch

Created on 2001-05-11 04:53 by bcsaller, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unit.diff bcsaller, 2001-05-11 04:53 path inspection
Messages (2)
msg36569 - (view) Author: Benjamin Saller (bcsaller) Date: 2001-05-11 04:53
Some times it is helpful to know the directory that 
tests are being run from so that they can collect 
their test data. If for example you have a parser and 
some test files finding those file reguardless of how 
the test is called is helpful to the test author.

TestCase has been extended to allow for this. When a 
testCase instance needs to find a data file relative 
to itself it can now say

class TestFoo(TestCase):
  def checkFoo(self):   
   dirname = self.getPath()
   # or
   filename = self.getPath("foo.data")

If TestFoo.py is in /home/user/python/tests then
dirname == /home/user/python/tests 
and 
filename == /home/user/python/tests/foo.data


There is not cost if this feature is not invoked.
msg36570 - (view) Author: Steve Purcell (purcell) (Python triager) Date: 2001-05-14 01:02
Logged In: YES 
user_id=21477

This method is helpful for *some* test environments, but as
the docs mention, 'unittest.py' aims to provide only
functionality common to all testing environments.

What usually happens is that each project has its own
'BaseTestCase' class that provides site-specific add-ons
(such as 'getPath()').

I will keep this patch and use it later in documentation to
illustrate the principle of customising a base TestCase
subclass for a specific test environment.
History
Date User Action Args
2022-04-10 16:04:03adminsetgithub: 34493
2001-05-11 04:53:51bcsallercreate