Merge lp:~kolmis/wxbanker/runnable-tests into lp:wxbanker

Proposed by Karel Kolman
Status: Merged
Merged at revision: not available
Proposed branch: lp:~kolmis/wxbanker/runnable-tests
Merge into: lp:wxbanker
Diff against target: None lines
To merge this branch: bzr merge lp:~kolmis/wxbanker/runnable-tests
Reviewer Review Type Date Requested Status
Michael Rooney Pending
Review via email: mp+6469@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Karel Kolman (kolmis) wrote :

Single test modules should be runnable IMHO.
I also separated the module path insertion into a module testbase.py.

Revision history for this message
Michael Rooney (mrooney) wrote :

> Single test modules should be runnable IMHO.
> I also separated the module path insertion into a module testbase.py.

This all looks pretty good. Although running the guitests later in the sequence ends up giving me some "ProgrammingError: Cannot operate on a closed database." Do you get those too? I guess it should either be worked around by a custom sort, or I could try to figure out what isn't closing down properly.

lp:~kolmis/wxbanker/runnable-tests updated
225. By Karel Kolman

GuiTests - add Publisher.unsubAll() call to test setUp method

Revision history for this message
Karel Kolman (kolmis) wrote :

Didn't happen on my side, otherwise I wouldn't propose a merge :)

It seems the problem could be guitests were called after modeltests on your machine, adding a Publisher.unsubAll() to guitests.py seems to solve the problem.

Revision history for this message
Karel Kolman (kolmis) wrote :

and the guitests.py fix is pushed in r225...

Revision history for this message
Michael Rooney (mrooney) wrote :

On Tue, May 12, 2009 at 12:59 PM, Karel Kolman <email address hidden> wrote:
> and the guitests.py fix is pushed in r225...

Yes, that fixes the issue but also causes one of the UI tests to no
longer test for a regression. I added an assert to test for the
condition it actually wants so that isn't hidden anymore and should
fail. I think the proper place is to figure out what in the modeltests
isn't unsubscribing and fix it, so I'll take a look at it.

Also I cleaned up the way alltests was getting the modules, so it
doesn't need a filter or a lambda, and fixed the name of the copyright
of testbase :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/alltests.py'
2--- tests/alltests.py 2009-05-12 06:32:46 +0000
3+++ tests/alltests.py 2009-05-12 13:55:37 +0000
4@@ -18,12 +18,14 @@
5 # You should have received a copy of the GNU General Public License
6 # along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
7
8-import os, sys; sys.path.insert(0, os.path.dirname(__file__))
9-import unittest
10-
11-# Specify the modules to test.
12-# TODO: assemble the list by listing .py files in this directory
13-modules = ["csvimportertests", "guitests", "modeltests", "localetests"]
14+import testbase
15+import unittest, os
16+
17+# find the modules to test
18+ignores = ['__init__.py', 'testbase.py', 'alltests.py']
19+files = filter(lambda x: x.endswith(".py") and x not in ignores, os.listdir(os.path.dirname(__file__)))
20+modules = [m.replace(".py", "") for m in files]
21+
22 suite = unittest.TestLoader().loadTestsFromNames(modules)
23
24 def main():
25
26=== modified file 'tests/csvimportertests.py'
27--- tests/csvimportertests.py 2009-05-12 06:32:46 +0000
28+++ tests/csvimportertests.py 2009-05-12 13:37:15 +0000
29@@ -18,7 +18,7 @@
30 # You should have received a copy of the GNU General Public License
31 # along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
32
33-import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
34+import testbase
35 import unittest
36 from csvimporter import CsvImporter
37
38@@ -31,3 +31,6 @@
39 decimalSeparator = ','
40 self.assertEquals(self.importer.parseAmount('-1 000,00', decimalSeparator), -1000.0)
41 self.assertEquals(self.importer.parseAmount('$ -1 000,00 ', decimalSeparator), -1000.0)
42+
43+if __name__ == "__main__":
44+ unittest.main()
45
46=== modified file 'tests/guitests.py' (properties changed: -x to +x)
47--- tests/guitests.py 2009-05-12 06:32:46 +0000
48+++ tests/guitests.py 2009-05-12 13:37:15 +0000
49@@ -18,9 +18,7 @@
50 # You should have received a copy of the GNU General Public License
51 # along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
52
53-# Here we must insert since if wxbanker is installed on the system this would
54-# otherwise pull in that package first.
55-import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
56+import testbase, os
57 import controller, unittest, wxbanker
58 from wx.lib.pubsub import Publisher
59
60@@ -51,4 +49,7 @@
61 if os.path.exists("test.db"):
62 os.remove("test.db")
63 if os.path.exists(self.ConfigPathBackup):
64- os.rename(self.ConfigPathBackup, self.ConfigPath)
65\ No newline at end of file
66+ os.rename(self.ConfigPathBackup, self.ConfigPath)
67+
68+if __name__ == "__main__":
69+ unittest.main()
70
71=== modified file 'tests/localetests.py' (properties changed: -x to +x)
72--- tests/localetests.py 2009-05-12 06:32:46 +0000
73+++ tests/localetests.py 2009-05-12 13:37:15 +0000
74@@ -18,7 +18,7 @@
75 # You should have received a copy of the GNU General Public License
76 # along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
77
78-import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
79+import testbase
80 import unittest, locale, currencies as c
81
82 class LocaleTests(unittest.TestCase):
83@@ -43,3 +43,6 @@
84 # The test is that none of these calls throw an exception.
85 for curr in c.CurrencyList:
86 curr().float2str(1000)
87+
88+if __name__ == "__main__":
89+ unittest.main()
90
91=== modified file 'tests/modeltests.py' (properties changed: -x to +x)
92--- tests/modeltests.py 2009-05-12 06:32:46 +0000
93+++ tests/modeltests.py 2009-05-12 13:37:15 +0000
94@@ -18,7 +18,7 @@
95 # You should have received a copy of the GNU General Public License
96 # along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
97
98-import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
99+import testbase, os
100 import controller, unittest
101 from wx.lib.pubsub import Publisher
102
103@@ -231,4 +231,7 @@
104 if os.path.exists("test.db"):
105 os.remove("test.db")
106 if os.path.exists(self.ConfigPathBackup):
107- os.rename(self.ConfigPathBackup, self.ConfigPath)
108\ No newline at end of file
109+ os.rename(self.ConfigPathBackup, self.ConfigPath)
110+
111+if __name__ == "__main__":
112+ unittest.main()
113
114=== added file 'tests/testbase.py'
115--- tests/testbase.py 1970-01-01 00:00:00 +0000
116+++ tests/testbase.py 2009-05-12 13:37:15 +0000
117@@ -0,0 +1,31 @@
118+#!/usr/bin/env python
119+# -*- coding: utf-8 -*-
120+# https://launchpad.net/wxbanker
121+# alltests.py: Copyright 2007-2009 Mike Rooney <mrooney@ubuntu.com>
122+#
123+# This file is part of wxBanker.
124+#
125+# wxBanker is free software: you can redistribute it and/or modify
126+# it under the terms of the GNU General Public License as published by
127+# the Free Software Foundation, either version 3 of the License, or
128+# (at your option) any later version.
129+#
130+# wxBanker is distributed in the hope that it will be useful,
131+# but WITHOUT ANY WARRANTY; without even the implied warranty of
132+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133+# GNU General Public License for more details.
134+#
135+# You should have received a copy of the GNU General Public License
136+# along with wxBanker. If not, see <http://www.gnu.org/licenses/>.
137+
138+import os, sys
139+
140+# make sure path contains both the test dir and its parent (wxbanker root dir)
141+# we must insert since if wxbanker is installed on the system this would
142+# otherwise pull in that package first.
143+
144+testdir = os.path.dirname(__file__)
145+rootdir = os.path.dirname(testdir)
146+
147+sys.path.insert(0, testdir)
148+sys.path.insert(0, rootdir)

Subscribers

People subscribed via source and target branches

to all changes: