Merge lp:~mvo/software-center/testenv-cleanup into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2654
Proposed branch: lp:~mvo/software-center/testenv-cleanup
Merge into: lp:software-center
Diff against target: 1186 lines (+158/-241)
54 files modified
softwarecenter/testutils.py (+18/-0)
test/gtk3/test_app_view.py (+3/-3)
test/gtk3/test_appdetailsview.py (+2/-7)
test/gtk3/test_appmanager.py (+2/-2)
test/gtk3/test_appstore2.py (+3/-3)
test/gtk3/test_appview.py (+2/-6)
test/gtk3/test_catview.py (+2/-9)
test/gtk3/test_custom_lists.py (+2/-5)
test/gtk3/test_dialogs.py (+2/-8)
test/gtk3/test_globalpane.py (+4/-12)
test/gtk3/test_install_progress.py (+3/-8)
test/gtk3/test_installedpane.py (+2/-8)
test/gtk3/test_navhistory.py (+2/-3)
test/gtk3/test_panes.py (+2/-8)
test/gtk3/test_purchase.py (+7/-13)
test/gtk3/test_search.py (+2/-8)
test/gtk3/test_unity_launcher_integration.py (+2/-5)
test/gtk3/test_views.py (+2/-10)
test/gtk3/test_widgets.py (+3/-8)
test/test_addons.py (+4/-2)
test/test_aptcache.py (+3/-3)
test/test_aptd.py (+2/-2)
test/test_apthistory.py (+4/-3)
test/test_cat_parsing.py (+3/-2)
test/test_channels.py (+3/-4)
test/test_cmdfiner.py (+2/-3)
test/test_database.py (+2/-4)
test/test_debfileapplication.py (+2/-3)
test/test_description_norm.py (+2/-2)
test/test_distro.py (+2/-4)
test/test_downloader.py (+2/-2)
test/test_enquire.py (+4/-6)
test/test_gwibber.py (+3/-2)
test/test_htmlize.py (+2/-2)
test/test_launchpad.py (+2/-4)
test/test_login_backend.py (+3/-4)
test/test_mime.py (+2/-3)
test/test_netstatus.py (+3/-2)
test/test_origin.py (+3/-3)
test/test_package_info.py (+2/-3)
test/test_plugin.py (+2/-3)
test/test_ppa_iconfilename.py (+2/-2)
test/test_purchase_backend.py (+2/-4)
test/test_reinstall_purchased.py (+2/-4)
test/test_reviews.py (+4/-9)
test/test_rnr_api.py (+4/-4)
test/test_scagent.py (+2/-8)
test/test_startup.py (+2/-3)
test/test_testutils.py (+2/-2)
test/test_ubuntu_sso_api.py (+3/-4)
test/test_utils.py (+4/-3)
test/test_where_is_it.py (+2/-2)
test/test_xapian.py (+4/-4)
test/xapian_query.py (+3/-0)
To merge this branch: bzr merge lp:~mvo/software-center/testenv-cleanup
Reviewer Review Type Date Requested Status
Łukasz Czyżykowski (community) Approve
software-store-developers Pending
Review via email: mp+88700@code.launchpad.net

Description of the change

This branch addresses some of the test failures and cleans the code up so that the environment setup is done
in a single place.

To post a comment you must log in.
Revision history for this message
Łukasz Czyżykowski (lukasz-czyzykowski) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/testutils.py'
2--- softwarecenter/testutils.py 2011-12-15 15:26:03 +0000
3+++ softwarecenter/testutils.py 2012-01-16 14:45:27 +0000
4@@ -18,8 +18,11 @@
5
6 import os
7 import subprocess
8+import sys
9+import tempfile
10 import time
11
12+
13 m_dbus = m_polkit = m_aptd = None
14 def start_dummy_backend():
15 global m_dbus, m_polkit, m_aptd
16@@ -133,3 +136,18 @@
17 app._details = details_mock
18 app.get_details = lambda db: app._details
19 return app
20+
21+def setup_test_env():
22+ """ Setup environment suitable for running the test/* code in a checkout.
23+ This includes PYTHONPATH, sys.path and softwarecenter.paths.datadir.
24+ """
25+ basedir = os.path.dirname(__file__)
26+ while not os.path.exists(
27+ os.path.join(basedir, "softwarecenter/__init__.py")):
28+ basedir = os.path.abspath(os.path.join(basedir, ".."))
29+ #print basedir, __file__, os.path.realpath(__file__)
30+ sys.path.insert(0, basedir)
31+ os.environ["PYTHONPATH"] = basedir
32+ import softwarecenter.paths
33+ softwarecenter.paths.datadir = os.path.join(basedir, "data")
34+ softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR = tempfile.mkdtemp()
35
36=== modified file 'test/gtk3/test_app_view.py'
37--- test/gtk3/test_app_view.py 2011-08-24 11:41:54 +0000
38+++ test/gtk3/test_app_view.py 2012-01-16 14:45:27 +0000
39@@ -1,13 +1,13 @@
40+#!/usr/bin/python
41
42-import sys
43 import time
44 import unittest
45 import xapian
46
47 from gi.repository import Gtk
48
49-sys.path.insert(0,"../..")
50-sys.path.insert(0,"..")
51+from testutils import setup_test_env
52+setup_test_env()
53
54 from softwarecenter.db.enquire import AppEnquire
55 from softwarecenter.enums import SortMethods
56
57=== modified file 'test/gtk3/test_appdetailsview.py'
58--- test/gtk3/test_appdetailsview.py 2011-12-01 16:09:39 +0000
59+++ test/gtk3/test_appdetailsview.py 2012-01-16 14:45:27 +0000
60@@ -1,17 +1,12 @@
61 #!/usr/bin/python
62
63-#import os
64-import sys
65 import unittest
66
67-sys.path.insert(0,"../..")
68-sys.path.insert(0,"..")
69+from testutils import setup_test_env
70+setup_test_env()
71
72 from mock import Mock
73
74-import softwarecenter.paths
75-softwarecenter.paths.datadir = "../data"
76-
77 from softwarecenter.db.application import Application
78 from softwarecenter.testutils import get_mock_app_from_real_app, do_events
79 from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
80
81=== modified file 'test/gtk3/test_appmanager.py'
82--- test/gtk3/test_appmanager.py 2011-11-09 10:35:09 +0000
83+++ test/gtk3/test_appmanager.py 2012-01-16 14:45:27 +0000
84@@ -3,8 +3,8 @@
85 from mock import Mock
86 import unittest
87
88-import sys
89-sys.path.insert(0,"../")
90+from testutils import setup_test_env
91+setup_test_env()
92
93 import softwarecenter.paths
94 from softwarecenter.db.application import Application
95
96=== modified file 'test/gtk3/test_appstore2.py'
97--- test/gtk3/test_appstore2.py 2011-08-11 09:25:56 +0000
98+++ test/gtk3/test_appstore2.py 2012-01-16 14:45:27 +0000
99@@ -1,13 +1,13 @@
100+#!/usr/bin/python
101
102-import sys
103 import unittest
104 import xapian
105
106 from gi.repository import Gtk
107
108-sys.path.insert(0,"../..")
109-sys.path.insert(0,"..")
110
111+from testutils import setup_test_env
112+setup_test_env()
113 from softwarecenter.ui.gtk3.models.appstore2 import AppListStore
114 from softwarecenter.db.enquire import AppEnquire
115
116
117=== modified file 'test/gtk3/test_appview.py'
118--- test/gtk3/test_appview.py 2011-10-07 10:44:12 +0000
119+++ test/gtk3/test_appview.py 2012-01-16 14:45:27 +0000
120@@ -1,20 +1,16 @@
121 #!/usr/bin/python
122
123 from gi.repository import Gtk, GObject
124-import sys
125 import time
126 import unittest
127
128-sys.path.insert(0,"../..")
129-sys.path.insert(0,"..")
130+from testutils import setup_test_env
131+setup_test_env()
132
133 #from mock import Mock
134
135 TIMEOUT=300
136
137-import softwarecenter.paths
138-softwarecenter.paths.datadir = "../data"
139-
140 class TestViews(unittest.TestCase):
141
142 def test_appview_search_combo(self):
143
144=== modified file 'test/gtk3/test_catview.py'
145--- test/gtk3/test_catview.py 2011-10-05 09:09:24 +0000
146+++ test/gtk3/test_catview.py 2012-01-16 14:45:27 +0000
147@@ -1,16 +1,9 @@
148 from gi.repository import Gtk
149-import os
150-import sys
151 import time
152 import unittest
153
154-sys.path.insert(0,"../..")
155-sys.path.insert(0,"..")
156-
157-import softwarecenter.paths
158-# ensure datadir is pointing to the right place
159-softwarecenter.paths.datadir = os.path.join(
160- os.path.dirname(__file__), "..", "..", 'data')
161+from testutils import setup_test_env
162+setup_test_env()
163
164 from softwarecenter.enums import SortMethods
165
166
167=== modified file 'test/gtk3/test_custom_lists.py'
168--- test/gtk3/test_custom_lists.py 2011-11-17 03:23:24 +0000
169+++ test/gtk3/test_custom_lists.py 2012-01-16 14:45:27 +0000
170@@ -1,16 +1,13 @@
171 #!/usr/bin/python
172
173 from gi.repository import Gtk, GObject
174-import sys
175 import time
176 import unittest
177
178-sys.path.insert(0,"../..")
179-sys.path.insert(0,"..")
180+from testutils import setup_test_env
181+setup_test_env()
182
183 from softwarecenter.enums import XapianValues, ActionButtons
184-import softwarecenter.paths
185-softwarecenter.paths.datadir = "../data"
186
187 TIMEOUT=300
188
189
190=== modified file 'test/gtk3/test_dialogs.py'
191--- test/gtk3/test_dialogs.py 2011-10-11 12:39:31 +0000
192+++ test/gtk3/test_dialogs.py 2012-01-16 14:45:27 +0000
193@@ -1,16 +1,10 @@
194 #!/usr/bin/python
195
196 from gi.repository import Gtk, GObject
197-import os
198-import sys
199 import unittest
200
201-sys.path.insert(0,"..")
202-
203-# ensure datadir is pointing to the right place
204-import softwarecenter.paths
205-softwarecenter.paths.datadir = os.path.join(
206- os.path.dirname(__file__), "..", "..", 'data')
207+from testutils import setup_test_env
208+setup_test_env()
209
210 import softwarecenter.ui.gtk3.dialogs
211
212
213=== modified file 'test/gtk3/test_globalpane.py'
214--- test/gtk3/test_globalpane.py 2011-12-15 03:18:19 +0000
215+++ test/gtk3/test_globalpane.py 2012-01-16 14:45:27 +0000
216@@ -1,19 +1,11 @@
217 #!/usr/bin/python
218
219-import sys
220 import unittest
221
222-sys.path.insert(0,"../..")
223-sys.path.insert(0,"..")
224-
225-#from mock import Mock
226-
227-TIMEOUT=300
228-
229-import softwarecenter.paths
230-softwarecenter.paths.datadir = "../data"
231-
232-from softwarecenter.testutils import do_events
233+from testutils import setup_test_env
234+setup_test_env()
235+
236+from testutils import do_events
237
238 class TestGlobalPane(unittest.TestCase):
239
240
241=== modified file 'test/gtk3/test_install_progress.py'
242--- test/gtk3/test_install_progress.py 2011-11-15 10:54:54 +0000
243+++ test/gtk3/test_install_progress.py 2012-01-16 14:45:27 +0000
244@@ -1,17 +1,12 @@
245 #!/usr/bin/python
246
247 from gi.repository import Gtk
248-import sys
249 import time
250 import unittest
251
252-sys.path.insert(0,"../..")
253-sys.path.insert(0,"..")
254-
255-#from mock import Mock
256-
257-import softwarecenter.paths
258-softwarecenter.paths.datadir = "../data"
259+from testutils import setup_test_env
260+setup_test_env()
261+
262
263 from softwarecenter.db.application import Application
264 from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend
265
266=== modified file 'test/gtk3/test_installedpane.py'
267--- test/gtk3/test_installedpane.py 2011-11-17 03:34:17 +0000
268+++ test/gtk3/test_installedpane.py 2012-01-16 14:45:27 +0000
269@@ -1,20 +1,14 @@
270 #!/usr/bin/python
271
272 from gi.repository import Gtk, GObject
273-import sys
274 import time
275 import unittest
276
277-sys.path.insert(0,"../..")
278-sys.path.insert(0,"..")
279-
280-#from mock import Mock
281+from testutils import setup_test_env
282+setup_test_env()
283
284 TIMEOUT=300
285
286-import softwarecenter.paths
287-softwarecenter.paths.datadir = "../data"
288-
289 class TestInstalledPane(unittest.TestCase):
290
291 def test_installedpane(self):
292
293=== modified file 'test/gtk3/test_navhistory.py'
294--- test/gtk3/test_navhistory.py 2011-09-20 08:14:41 +0000
295+++ test/gtk3/test_navhistory.py 2012-01-16 14:45:27 +0000
296@@ -1,12 +1,11 @@
297 #!/usr/bin/python
298
299-import sys
300 import unittest
301
302 from mock import Mock
303
304-sys.path.insert(0,"../..")
305-sys.path.insert(0,"..")
306+from testutils import setup_test_env
307+setup_test_env()
308
309 from softwarecenter.ui.gtk3.session.navhistory import (
310 NavigationHistory, NavigationItem)
311
312=== modified file 'test/gtk3/test_panes.py'
313--- test/gtk3/test_panes.py 2011-09-07 02:20:57 +0000
314+++ test/gtk3/test_panes.py 2012-01-16 14:45:27 +0000
315@@ -1,19 +1,13 @@
316 #!/usr/bin/python
317
318 from gi.repository import Gtk, GObject
319-import sys
320 import unittest
321
322-sys.path.insert(0,"../..")
323-sys.path.insert(0,"..")
324-
325-#from mock import Mock
326+from testutils import setup_test_env
327+setup_test_env()
328
329 TIMEOUT=300
330
331-import softwarecenter.paths
332-softwarecenter.paths.datadir = "../data"
333-
334 class TestPanes(unittest.TestCase):
335
336 def test_availablepane(self):
337
338=== modified file 'test/gtk3/test_purchase.py'
339--- test/gtk3/test_purchase.py 2011-12-15 03:18:19 +0000
340+++ test/gtk3/test_purchase.py 2012-01-16 14:45:27 +0000
341@@ -1,24 +1,16 @@
342 #!/usr/bin/python
343
344-import os
345-import sys
346 import time
347 import unittest
348
349 from mock import Mock
350
351-sys.path.insert(0,"../..")
352-sys.path.insert(0,"..")
353+from testutils import setup_test_env, do_events
354+setup_test_env()
355
356-# overwrite early
357+from softwarecenter.ui.gtk3.app import SoftwareCenterAppGtk3
358+from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
359 import softwarecenter.paths
360-softwarecenter.paths.datadir = "../data"
361-
362-from softwarecenter.ui.gtk3.app import (
363- SoftwareCenterAppGtk3)
364-from softwarecenter.ui.gtk3.panes.availablepane import (
365- AvailablePane)
366-from softwarecenter.testutils import do_events
367
368 class TestPurchase(unittest.TestCase):
369
370@@ -63,7 +55,6 @@
371
372
373 def test_reinstall_previous_purchase_display(self):
374- os.environ["PYTHONPATH"]=".."
375 mock_options = Mock()
376 mock_options.display_navlog = False
377 mock_options.disable_apt_xapian_index = False
378@@ -71,6 +62,9 @@
379 xapiandb = "/var/cache/software-center/"
380 app = SoftwareCenterAppGtk3(
381 softwarecenter.paths.datadir, xapiandb, mock_options)
382+ # real app opens cache async
383+ app.cache.open()
384+ # show it
385 app.window_main.show_all()
386 app.available_pane.init_view()
387 self._p()
388
389=== modified file 'test/gtk3/test_search.py'
390--- test/gtk3/test_search.py 2011-10-07 10:44:12 +0000
391+++ test/gtk3/test_search.py 2012-01-16 14:45:27 +0000
392@@ -1,20 +1,14 @@
393 #!/usr/bin/python
394
395 from gi.repository import Gtk, GObject
396-import sys
397 import time
398 import unittest
399
400-sys.path.insert(0,"../..")
401-sys.path.insert(0,"..")
402-
403-#from mock import Mock
404+from testutils import setup_test_env
405+setup_test_env()
406
407 TIMEOUT=300
408
409-import softwarecenter.paths
410-softwarecenter.paths.datadir = "../data"
411-
412 class TestSearch(unittest.TestCase):
413
414 def test_installedpane(self):
415
416=== modified file 'test/gtk3/test_unity_launcher_integration.py'
417--- test/gtk3/test_unity_launcher_integration.py 2011-12-15 02:53:48 +0000
418+++ test/gtk3/test_unity_launcher_integration.py 2012-01-16 14:45:27 +0000
419@@ -1,19 +1,16 @@
420 #!/usr/bin/python
421
422 from gi.repository import Gtk
423-import sys
424 import time
425 import unittest
426
427 from mock import Mock
428
429-sys.path.insert(0,"../..")
430-sys.path.insert(0,"..")
431+from testutils import setup_test_env
432+setup_test_env()
433
434 # overwrite early
435-import softwarecenter.paths
436 import softwarecenter.utils
437-softwarecenter.paths.datadir = "../data"
438
439 from softwarecenter.enums import TransactionTypes
440 from softwarecenter.utils import convert_desktop_file_to_installed_location
441
442=== modified file 'test/gtk3/test_views.py'
443--- test/gtk3/test_views.py 2012-01-05 11:24:51 +0000
444+++ test/gtk3/test_views.py 2012-01-16 14:45:27 +0000
445@@ -1,21 +1,13 @@
446 #!/usr/bin/python
447
448 from gi.repository import Gtk, GObject
449-import sys
450 import unittest
451
452-sys.path.insert(0,"../..")
453-sys.path.insert(0,"..")
454-
455-#from mock import Mock
456+from testutils import setup_test_env
457+setup_test_env()
458
459 TIMEOUT=300
460
461-import softwarecenter.paths
462-softwarecenter.paths.datadir = "../data"
463-import os
464-os.environ["PYTHONPATH"] = "../"
465-
466 class TestViews(unittest.TestCase):
467
468 def test_viewswitcher(self):
469
470=== modified file 'test/gtk3/test_widgets.py'
471--- test/gtk3/test_widgets.py 2011-10-11 11:58:07 +0000
472+++ test/gtk3/test_widgets.py 2012-01-16 14:45:27 +0000
473@@ -2,18 +2,13 @@
474
475 from gi.repository import Gtk, GdkPixbuf, GObject
476 import os
477-import sys
478 import unittest
479
480 from mock import Mock
481
482-
483-sys.path.insert(0,"..")
484-
485-# ensure datadir is pointing to the right place
486-import softwarecenter.paths
487-softwarecenter.paths.datadir = os.path.join(
488- os.path.dirname(__file__), "..", "..", 'data')
489+from testutils import setup_test_env
490+setup_test_env()
491+
492
493 # window destory timeout
494 TIMEOUT=100
495
496=== added symlink 'test/gtk3/testutils.py'
497=== target is u'../../softwarecenter/testutils.py'
498=== modified file 'test/test_addons.py'
499--- test/test_addons.py 2011-09-28 16:01:02 +0000
500+++ test/test_addons.py 2012-01-16 14:45:27 +0000
501@@ -1,8 +1,10 @@
502 #!/usr/bin/python
503
504-import sys
505+
506 import unittest
507-sys.path.insert(0,"../")
508+
509+from testutils import setup_test_env
510+setup_test_env()
511
512 from softwarecenter.db.pkginfo import get_pkg_info
513
514
515=== modified file 'test/test_aptcache.py'
516--- test/test_aptcache.py 2011-07-14 14:42:36 +0000
517+++ test/test_aptcache.py 2012-01-16 14:45:27 +0000
518@@ -2,14 +2,14 @@
519
520 from gi.repository import GObject
521
522-import sys
523-sys.path.insert(0,"../")
524-
525 import apt
526 import logging
527 import time
528 import unittest
529
530+from testutils import setup_test_env
531+setup_test_env()
532+
533 from softwarecenter.db.pkginfo import get_pkg_info
534 from softwarecenter.utils import ExecutionTime
535
536
537=== modified file 'test/test_aptd.py'
538--- test/test_aptd.py 2011-11-28 23:28:52 +0000
539+++ test/test_aptd.py 2012-01-16 14:45:27 +0000
540@@ -1,12 +1,12 @@
541 #!/usr/bin/python
542
543 import os
544-import sys
545 import time
546 import unittest
547
548+from testutils import setup_test_env
549+setup_test_env()
550
551-sys.path.insert(0,"../")
552 from softwarecenter.backend.installbackend_impl.aptd import AptdaemonBackend
553 from defer import inline_callbacks
554 from mock import Mock
555
556=== modified file 'test/test_apthistory.py'
557--- test/test_apthistory.py 2011-07-14 14:42:36 +0000
558+++ test/test_apthistory.py 2012-01-16 14:45:27 +0000
559@@ -2,17 +2,18 @@
560
561 from gi.repository import GObject
562
563-import sys
564-sys.path.insert(0,"../")
565-
566 import apt
567 import datetime
568 import logging
569 import os
570 import subprocess
571+import sys
572 import time
573 import unittest
574
575+from testutils import setup_test_env
576+setup_test_env()
577+
578 from softwarecenter.db.history_impl.apthistory import AptHistory
579 from softwarecenter.utils import ExecutionTime
580
581
582=== modified file 'test/test_cat_parsing.py'
583--- test/test_cat_parsing.py 2011-06-06 09:59:08 +0000
584+++ test/test_cat_parsing.py 2012-01-16 14:45:27 +0000
585@@ -1,9 +1,10 @@
586 #!/usr/bin/python
587
588 import os
589-import sys
590 import unittest
591-sys.path.insert(0,"../")
592+
593+from testutils import setup_test_env
594+setup_test_env()
595
596 from softwarecenter.paths import XAPIAN_BASE_PATH
597
598
599=== modified file 'test/test_channels.py'
600--- test/test_channels.py 2011-11-09 11:04:33 +0000
601+++ test/test_channels.py 2012-01-16 14:45:27 +0000
602@@ -1,10 +1,9 @@
603 #!/usr/bin/python
604
605-
606-import sys
607-sys.path.insert(0,"../")
608-
609 import unittest
610+
611+from testutils import setup_test_env
612+setup_test_env()
613 from softwarecenter.testutils import get_test_db
614
615 class TestChannels(unittest.TestCase):
616
617=== modified file 'test/test_cmdfiner.py'
618--- test/test_cmdfiner.py 2011-03-22 13:51:20 +0000
619+++ test/test_cmdfiner.py 2012-01-16 14:45:27 +0000
620@@ -3,9 +3,8 @@
621 import apt
622 import unittest
623
624-import sys
625-sys.path.insert(0,"../")
626-
627+from testutils import setup_test_env
628+setup_test_env()
629 from softwarecenter.cmdfinder import CmdFinder
630
631 class TestCmdFinder(unittest.TestCase):
632
633=== modified file 'test/test_database.py'
634--- test/test_database.py 2012-01-05 09:53:52 +0000
635+++ test/test_database.py 2012-01-16 14:45:27 +0000
636@@ -1,8 +1,8 @@
637 #!/usr/bin/python
638
639
640-import sys
641-sys.path.insert(0,"../")
642+from testutils import setup_test_env
643+setup_test_env()
644
645 import apt
646 import os
647@@ -106,8 +106,6 @@
648 distro.get_codename = lambda: "natty"
649 # we test against the real https://software-center.ubuntu.com here
650 # so we need network
651- softwarecenter.paths.datadir="../data"
652- os.environ["PYTHONPATH"] = ".."
653 res = update_from_software_center_agent(db, cache, ignore_cache=True)
654 # check results
655 self.assertTrue(res)
656
657=== modified file 'test/test_debfileapplication.py'
658--- test/test_debfileapplication.py 2011-12-13 16:44:21 +0000
659+++ test/test_debfileapplication.py 2012-01-16 14:45:27 +0000
660@@ -1,11 +1,10 @@
661 #!/usr/bin/python
662
663-import sys
664 import unittest
665 import logging
666
667-sys.path.insert(0, '../')
668-
669+from testutils import setup_test_env
670+setup_test_env()
671
672 from softwarecenter.enums import PkgStates
673 from softwarecenter.db.debfile import DebFileApplication
674
675=== modified file 'test/test_description_norm.py'
676--- test/test_description_norm.py 2011-09-20 20:51:57 +0000
677+++ test/test_description_norm.py 2012-01-16 14:45:27 +0000
678@@ -2,10 +2,10 @@
679
680 import apt
681 import logging
682-import sys
683 import unittest
684
685-sys.path.insert(0,"../")
686+from testutils import setup_test_env
687+setup_test_env()
688 from softwarecenter.utils import normalize_package_description
689
690
691
692=== modified file 'test/test_distro.py'
693--- test/test_distro.py 2011-05-31 09:49:14 +0000
694+++ test/test_distro.py 2012-01-16 14:45:27 +0000
695@@ -1,11 +1,9 @@
696 #!/usr/bin/python
697
698-
699-import sys
700-sys.path.insert(0,"../")
701-
702 import unittest
703
704+from testutils import setup_test_env
705+setup_test_env()
706 from softwarecenter.distro import get_distro
707
708 class TestDistro(unittest.TestCase):
709
710=== modified file 'test/test_downloader.py'
711--- test/test_downloader.py 2012-01-06 14:01:23 +0000
712+++ test/test_downloader.py 2012-01-16 14:45:27 +0000
713@@ -3,11 +3,11 @@
714 from gi.repository import GObject
715
716 import os
717-import sys
718 import time
719 import unittest
720
721-sys.path.insert(0,"../")
722+from testutils import setup_test_env
723+setup_test_env()
724 from softwarecenter.utils import SimpleFileDownloader
725
726 class TestImageDownloader(unittest.TestCase):
727
728=== modified file 'test/test_enquire.py'
729--- test/test_enquire.py 2011-08-25 18:51:39 +0000
730+++ test/test_enquire.py 2012-01-16 14:45:27 +0000
731@@ -1,18 +1,16 @@
732 #!/usr/bin/python
733
734-
735-import sys
736-sys.path.insert(0,"../")
737+from gi.repository import Gtk
738
739 import time
740 import unittest
741 import xapian
742
743+from testutils import setup_test_env
744+setup_test_env()
745+from softwarecenter.db.appfilter import AppFilter
746 from softwarecenter.db.enquire import AppEnquire
747-
748-from gi.repository import Gtk
749 from softwarecenter.testutils import get_test_db, get_test_pkg_info
750-from softwarecenter.db.appfilter import AppFilter
751
752 class TestEnquire(unittest.TestCase):
753
754
755=== modified file 'test/test_gwibber.py'
756--- test/test_gwibber.py 2011-02-11 08:25:40 +0000
757+++ test/test_gwibber.py 2012-01-16 14:45:27 +0000
758@@ -1,9 +1,10 @@
759 #!/usr/bin/python
760
761 import os
762-import sys
763 import unittest
764-sys.path.insert(0,"../")
765+
766+from testutils import setup_test_env
767+setup_test_env()
768
769 class TestGwibber(unittest.TestCase):
770 """ tests the "where is it in the menu" code """
771
772=== modified file 'test/test_htmlize.py'
773--- test/test_htmlize.py 2011-06-20 07:48:13 +0000
774+++ test/test_htmlize.py 2012-01-16 14:45:27 +0000
775@@ -1,7 +1,7 @@
776 #!/usr/bin/python
777
778-import sys
779-sys.path.insert(0, "..")
780+from testutils import setup_test_env
781+setup_test_env()
782 from softwarecenter.utils import htmlize_package_description
783
784 #file-roller
785
786=== modified file 'test/test_launchpad.py'
787--- test/test_launchpad.py 2011-07-14 14:42:36 +0000
788+++ test/test_launchpad.py 2012-01-16 14:45:27 +0000
789@@ -1,12 +1,10 @@
790 #!/usr/bin/python
791
792 from gi.repository import GObject
793-
794-import sys
795-sys.path.insert(0,"../")
796-
797 import unittest
798
799+from testutils import setup_test_env
800+setup_test_env()
801 from softwarecenter.backend.launchpad import GLaunchpad
802
803 class testUbuntuSSO(unittest.TestCase):
804
805=== modified file 'test/test_login_backend.py'
806--- test/test_login_backend.py 2011-06-11 07:59:59 +0000
807+++ test/test_login_backend.py 2012-01-16 14:45:27 +0000
808@@ -1,11 +1,10 @@
809 #!/usr/bin/python
810
811-
812-import sys
813-sys.path.insert(0,"../")
814-
815 import os
816 import unittest
817+
818+from testutils import setup_test_env
819+setup_test_env()
820 from softwarecenter.backend.login_sso import (get_sso_backend,
821 LoginBackendDbusSSO,
822 LoginBackendDbusSSOFake)
823
824=== modified file 'test/test_mime.py'
825--- test/test_mime.py 2011-05-18 08:26:04 +0000
826+++ test/test_mime.py 2012-01-16 14:45:27 +0000
827@@ -1,11 +1,10 @@
828 #!/usr/bin/python
829
830-import sys
831-sys.path.insert(0,"../")
832-
833 import os
834 import unittest
835
836+from testutils import setup_test_env
837+setup_test_env()
838 from softwarecenter.db.database import StoreDatabase
839 from softwarecenter.db.pkginfo import get_pkg_info
840 from softwarecenter.db.update import rebuild_database
841
842=== modified file 'test/test_netstatus.py'
843--- test/test_netstatus.py 2011-10-20 16:34:14 +0000
844+++ test/test_netstatus.py 2012-01-16 14:45:27 +0000
845@@ -1,8 +1,9 @@
846 #!/usr/bin/python
847
848-import sys
849 import unittest
850-sys.path.insert(0,"../")
851+
852+from testutils import setup_test_env
853+setup_test_env()
854
855 class TestNetstatus(unittest.TestCase):
856 """ tests the netstaus utils """
857
858=== modified file 'test/test_origin.py'
859--- test/test_origin.py 2011-06-06 08:49:12 +0000
860+++ test/test_origin.py 2012-01-16 14:45:27 +0000
861@@ -1,10 +1,10 @@
862 #!/usr/bin/python
863
864-import sys
865+import apt
866 import unittest
867-sys.path.insert(0,"../")
868
869-import apt
870+from testutils import setup_test_env
871+setup_test_env()
872
873 class TestOrigins(unittest.TestCase):
874 """ tests the origin code """
875
876=== modified file 'test/test_package_info.py'
877--- test/test_package_info.py 2011-11-21 13:03:36 +0000
878+++ test/test_package_info.py 2012-01-16 14:45:27 +0000
879@@ -1,11 +1,10 @@
880 #!/usr/bin/python
881
882-import sys
883-sys.path.insert(0,"../")
884-
885 import logging
886 import unittest
887
888+from testutils import setup_test_env
889+setup_test_env()
890 from softwarecenter.db.pkginfo import _Package, _Version
891 from softwarecenter.db.pkginfo_impl.aptcache import AptCache
892 # from softwarecenter.db.pkginfo_impl.packagekit import PackagekitInfo
893
894=== modified file 'test/test_plugin.py'
895--- test/test_plugin.py 2011-11-10 10:30:57 +0000
896+++ test/test_plugin.py 2012-01-16 14:45:27 +0000
897@@ -1,11 +1,10 @@
898 #!/usr/bin/python
899
900-import sys
901-sys.path.insert(0,"../")
902-
903 import logging
904 import unittest
905
906+from testutils import setup_test_env
907+setup_test_env()
908 from softwarecenter.plugin import PluginManager
909
910 class MockApp(object):
911
912=== modified file 'test/test_ppa_iconfilename.py'
913--- test/test_ppa_iconfilename.py 2011-12-19 12:25:59 +0000
914+++ test/test_ppa_iconfilename.py 2012-01-16 14:45:27 +0000
915@@ -1,9 +1,9 @@
916 #!/usr/bin/python
917
918-import sys
919 import unittest
920
921-sys.path.insert(0,"../")
922+from testutils import setup_test_env
923+setup_test_env()
924 from softwarecenter.distro.Ubuntu import Ubuntu
925
926 class MockCache(object):
927
928=== modified file 'test/test_purchase_backend.py'
929--- test/test_purchase_backend.py 2011-12-12 09:15:52 +0000
930+++ test/test_purchase_backend.py 2012-01-16 14:45:27 +0000
931@@ -1,17 +1,15 @@
932 #!/usr/bin/python
933
934 import os
935-import sys
936 import time
937 import unittest
938
939 from gi.repository import GObject, Gtk
940 from mock import Mock
941
942-sys.path.insert(0, "..")
943-
944+from testutils import setup_test_env
945+setup_test_env()
946 from softwarecenter.db.application import Application
947-
948 from softwarecenter.backend import get_install_backend
949
950 #import softwarecenter.log
951
952=== modified file 'test/test_reinstall_purchased.py'
953--- test/test_reinstall_purchased.py 2011-08-25 19:22:13 +0000
954+++ test/test_reinstall_purchased.py 2012-01-16 14:45:27 +0000
955@@ -1,9 +1,5 @@
956 #!/usr/bin/python
957
958-
959-import sys
960-sys.path.insert(0,"../")
961-
962 import apt_pkg
963 import apt
964 import logging
965@@ -11,6 +7,8 @@
966 import unittest
967 import xapian
968
969+from testutils import setup_test_env
970+setup_test_env()
971 from softwarecenter.enums import XapianValues
972 from softwarecenter.db.database import StoreDatabase
973 from softwarecenter.db.update import add_from_purchased_but_needs_reinstall_data
974
975=== modified file 'test/test_reviews.py'
976--- test/test_reviews.py 2012-01-05 14:53:25 +0000
977+++ test/test_reviews.py 2012-01-16 14:45:27 +0000
978@@ -1,21 +1,16 @@
979 #!/usr/bin/python
980
981 import os
982-import tempfile
983 import unittest
984
985-import sys
986-sys.path.insert(0,"../")
987-
988 from gi.repository import GObject
989
990-import softwarecenter.paths
991-softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR = tempfile.mkdtemp()
992-softwarecenter.paths.datadir = "../data"
993-
994+from testutils import setup_test_env
995+setup_test_env()
996 from softwarecenter.backend.reviews.rnr import (
997 ReviewLoaderSpawningRNRClient as ReviewLoader)
998-from softwarecenter.testutils import (get_test_pkg_info, get_test_db)
999+from softwarecenter.testutils import get_test_pkg_info, get_test_db
1000+
1001
1002 class TestReviewLoader(unittest.TestCase):
1003
1004
1005=== modified file 'test/test_rnr_api.py'
1006--- test/test_rnr_api.py 2011-06-21 15:57:45 +0000
1007+++ test/test_rnr_api.py 2012-01-16 14:45:27 +0000
1008@@ -1,10 +1,10 @@
1009 #!/usr/bin/python
1010
1011-
1012-import sys
1013-sys.path.insert(0,"../")
1014-
1015 import unittest
1016+
1017+from testutils import setup_test_env
1018+setup_test_env()
1019+
1020 from softwarecenter.backend.piston.rnrclient import RatingsAndReviewsAPI
1021 from softwarecenter.backend.piston.rnrclient_fake import RatingsAndReviewsAPI as RatingsAndReviewsAPIFake
1022
1023
1024=== modified file 'test/test_scagent.py'
1025--- test/test_scagent.py 2011-08-05 15:32:20 +0000
1026+++ test/test_scagent.py 2012-01-16 14:45:27 +0000
1027@@ -1,24 +1,18 @@
1028 #!/usr/bin/python
1029
1030 from gi.repository import GObject
1031-import os
1032-import os.path
1033 import unittest
1034
1035-
1036-import sys
1037-sys.path.insert(0,"../")
1038+from testutils import setup_test_env
1039+setup_test_env()
1040
1041 from softwarecenter.backend.scagent import SoftwareCenterAgent
1042-import softwarecenter.paths
1043
1044 class TestSCAgent(unittest.TestCase):
1045 """ tests software-center-agent """
1046
1047 def setUp(self):
1048 self.loop = GObject.MainLoop(GObject.main_context_default())
1049- softwarecenter.paths.datadir = "../data"
1050- os.environ["PYTHONPATH"] = os.path.abspath("..")
1051 self.error = False
1052
1053 def on_query_done(self, scagent, data):
1054
1055=== modified file 'test/test_startup.py'
1056--- test/test_startup.py 2011-03-11 19:14:20 +0000
1057+++ test/test_startup.py 2012-01-16 14:45:27 +0000
1058@@ -3,11 +3,11 @@
1059 import pickle
1060 import os
1061 import subprocess
1062-import sys
1063 import time
1064 import unittest
1065
1066-sys.path.insert(0, "..")
1067+from testutils import setup_test_env
1068+setup_test_env()
1069
1070
1071 # FIXME:
1072@@ -35,7 +35,6 @@
1073 print self.revno_to_times_list
1074
1075 def create_ui_and_return_time_to_visible(self):
1076- os.environ["PYTHONPATH"] = ".."
1077 now = time.time()
1078 # we get the time on stdout and detailed stats on stderr
1079 p = subprocess.Popen(["./software-center", "--measure-startup-time"],
1080
1081=== modified file 'test/test_testutils.py'
1082--- test/test_testutils.py 2011-08-19 19:45:36 +0000
1083+++ test/test_testutils.py 2012-01-16 14:45:27 +0000
1084@@ -7,8 +7,8 @@
1085 import time
1086 from gi.repository import GObject
1087
1088-import sys
1089-sys.path.insert(0,"../")
1090+from testutils import setup_test_env
1091+setup_test_env()
1092
1093 from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend
1094 from softwarecenter.backend.installbackend_impl.aptd import get_dbus_bus
1095
1096=== modified file 'test/test_ubuntu_sso_api.py'
1097--- test/test_ubuntu_sso_api.py 2012-01-05 15:26:28 +0000
1098+++ test/test_ubuntu_sso_api.py 2012-01-16 14:45:27 +0000
1099@@ -1,11 +1,10 @@
1100 #!/usr/bin/python
1101
1102-
1103-import sys
1104-sys.path.insert(0,"../")
1105-
1106 import os
1107 import unittest
1108+
1109+from testutils import setup_test_env
1110+setup_test_env()
1111 from softwarecenter.backend.ubuntusso import (UbuntuSSOAPIFake,
1112 UbuntuSSOAPI,
1113 get_ubuntu_sso_backend,
1114
1115=== modified file 'test/test_utils.py'
1116--- test/test_utils.py 2011-11-04 14:52:52 +0000
1117+++ test/test_utils.py 2012-01-16 14:45:27 +0000
1118@@ -1,10 +1,11 @@
1119 #!/usr/bin/python
1120
1121 import os
1122-import sys
1123 import unittest
1124-sys.path.insert(0,"../")
1125-
1126+
1127+
1128+from testutils import setup_test_env
1129+setup_test_env()
1130 from softwarecenter.utils import (decode_xml_char_reference,
1131 release_filename_in_lists_from_deb_line,
1132 get_http_proxy_string_from_libproxy,
1133
1134=== modified file 'test/test_where_is_it.py'
1135--- test/test_where_is_it.py 2011-08-19 09:56:15 +0000
1136+++ test/test_where_is_it.py 2012-01-16 14:45:27 +0000
1137@@ -1,10 +1,10 @@
1138 #!/usr/bin/python
1139
1140 import os
1141-import sys
1142 import unittest
1143-sys.path.insert(0,"../")
1144
1145+from testutils import setup_test_env
1146+setup_test_env()
1147 from softwarecenter.paths import XAPIAN_BASE_PATH
1148 from softwarecenter.ui.gtk3.gmenusearch import GMenuSearcher
1149 from softwarecenter.db.pkginfo import get_pkg_info
1150
1151=== modified file 'test/test_xapian.py'
1152--- test/test_xapian.py 2011-06-06 08:49:12 +0000
1153+++ test/test_xapian.py 2012-01-16 14:45:27 +0000
1154@@ -1,12 +1,12 @@
1155 #!/usr/bin/python
1156
1157-
1158-import sys
1159-sys.path.insert(0,"../")
1160-
1161 import unittest
1162 import os
1163 import xapian
1164+
1165+from testutils import setup_test_env
1166+setup_test_env()
1167+
1168 from softwarecenter.enums import XapianValues
1169 from softwarecenter.db.update import rebuild_database
1170
1171
1172=== added symlink 'test/testutils.py'
1173=== target is u'../softwarecenter/testutils.py'
1174=== modified file 'test/xapian_query.py'
1175--- test/xapian_query.py 2011-05-18 08:26:04 +0000
1176+++ test/xapian_query.py 2012-01-16 14:45:27 +0000
1177@@ -6,6 +6,9 @@
1178
1179 from softwarecenter.enums import XAPIAN_VALUE_POPCON
1180
1181+from testutils import setup_test_env
1182+setup_test_env()
1183+
1184 if __name__ == "__main__":
1185
1186 search_term = sys.argv[1]

Subscribers

People subscribed via source and target branches