Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#3700 closed defect (fixed)

Unit tests don't take /etc/trac.ini into account

Reported by: Manuzhai Owned by: Christian Boos
Priority: low Milestone: 0.10
Component: general Version: 0.10b1
Severity: minor Keywords:
Cc: manuzhai@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I'm working on a community buildbot testing Trac against Python trunk and Python 2.5. As part of this, I'm first checking to see if the unit tests succeed against Python 2.4 (so that any failures turning up in the buildbot aren't false positives).

trac/tests/config.py has the test_sections.py(), but it's failing for me:

======================================================================
FAIL: test_sections (trac.tests.config.ConfigurationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/manuzhai/src/trac/trac/tests/config.py", line 150, in test_sections
    self.assertEquals(['a', 'b'], config.sections())
AssertionError: ['a', 'b'] != ['a', 'attachment', 'b', 'components', 'header_logo', 'logging', 'mimeviewer', 'notification', 'project', 'ticket', 'timeline', 'trac']

----------------------------------------------------------------------

I'd say this is because I have an /etc/trac.ini that's taken into account by the Configuration class, and so this test should succeed. There should probably be tests to take into account /etc/trac.ini, or an option to ignore the central .ini.

Attachments (1)

3700.diff (5.3 KB ) - added by Christian Boos 18 years ago.
Insulate most tests from the global trac.ini

Download all attachments as: .zip

Change History (6)

comment:1 by Christian Boos, 18 years ago

Milestone: 0.10.1
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

I think we should find a way to programmatically set the global trac.ini file. That would fix the issue and enable us to unit-test the behavior of the global trac.ini.

e.g.

Index: config.py
===================================================================
--- config.py	(revision 3717)
+++ config.py	(working copy)
@@ -148,7 +148,12 @@
     def test_sections(self):
         self._write(['[a]', 'option = x', '[b]', 'option = y'])
         config = Configuration(self.filename)
-        self.assertEquals(['a', 'b'], config.sections())
+        # insulate us from "real" global trac.ini (ref. #3700)
+        from ConfigParser import ConfigParser
+        config.site_parser = ConfigParser()
+        self.assertEquals(['a', 'b'], config.sections()) 
+        config.set('c', 'key', 'value')
+        self.assertEquals(['a', 'b', 'c'], config.sections())
 
     def test_options(self):
         self._write(['[a]', 'option = x', '[b]', 'option = y'])

by Christian Boos, 18 years ago

Attachment: 3700.diff added

Insulate most tests from the global trac.ini

comment:2 by Christian Boos, 18 years ago

Looking at #3701, it seems that it would be a better idea if all the unit tests could be insulated from the global trac.ini.

attachment:3700.diff does that, on top of r3717.

Depending on feedback, might go in milestone:0.10.

comment:3 by Manuzhai, 18 years ago

I would agree that it would be a good idea to not look at the global trac.ini.

I hope this can go in.

comment:4 by Christian Boos, 18 years ago

The above patch was committed in r3721, but I believe there are other uses of Configuration within tests that can still suffer from the problem (in particular, the one from #3701).

comment:5 by Christian Boos, 18 years ago

Milestone: 0.10.10.10
Resolution: fixed
Status: assignedclosed

Ok, actually r3721 should have fixed #3701 as well. Now with r3722, all tests requiring a Configuration object should now be insulated from the content of the global trac.ini.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.