test_signal_crashes.py uses user's configuration file

Bug #1728110 reported by Brian Murray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Confirmed
Undecided
Unassigned

Bug Description

The apport test_test_signal_crashes.py will read ~/.config/apport/settings and if you have the following in it:

[main]
unpackaged: True

Then the tests, unpackaged_binary and unpackaged_script at least, will fail because a .crash file ends up being created for those when they should not.

I tried resolving it by manually setting apport.fileutils._config_file but for some reason that too didn't work!

 $ bzr cdiff test/test_signal_crashes.py
=== modified file 'test/test_signal_crashes.py'
--- test/test_signal_crashes.py 2017-07-18 18:20:51 +0000
+++ test/test_signal_crashes.py 2017-10-27 17:05:28 +0000
@@ -48,6 +48,12 @@
         self.report_dir = tempfile.mkdtemp()
         os.environ['APPORT_REPORT_DIR'] = self.report_dir

+ # don't user user configuration
+ self.orig_config_file = apport.fileutils._config_file
+ f = tempfile.NamedTemporaryFile()
+ apport.fileutils._config_file = f.name
+ f.close()
+
         self.workdir = tempfile.mkdtemp()

         # move aside current ignore file
@@ -69,6 +75,9 @@
         shutil.rmtree(self.report_dir)
         shutil.rmtree(self.workdir)

+ # restore configuration
+ apport.fileutils._config_file = self.orig_config_file
+
         # clean up our ignore file
         if os.path.exists(ifpath):
             os.unlink(ifpath)

Changed in apport:
status: New → Confirmed
Revision history for this message
Steve Langasek (vorlon) wrote :

Suggest handling this by setting XDG_CONFIG_HOME or HOME in the environment of the tests, pointing to a pristine directory.

tags: added: id-59f36d42d7de21cc9c1cbaae
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.