Merge lp:~bryce/quickly/template_tests into lp:quickly

Proposed by Bryce Harrington
Status: Rejected
Rejected by: Michael Terry
Proposed branch: lp:~bryce/quickly/template_tests
Merge into: lp:quickly
Diff against target: 36 lines (+26/-0)
2 files modified
data/templates/ubuntu-application/project_root/run-tests (+7/-0)
data/templates/ubuntu-application/project_root/tests/test_example (+19/-0)
To merge this branch: bzr merge lp:~bryce/quickly/template_tests
Reviewer Review Type Date Requested Status
Michael Terry (community) Needs Fixing
Review via email: mp+47172@code.launchpad.net

Description of the change

Stubs in a test directory, run script, and example test.

Opportunistic programmers may not normally think to write tests, but we all know how important they can be for ongoing maintenance of an application. In case they don't know how to set up a unittest framework, this removes that roadblock from them.

Obviously this could be improved upon a lot, but my thinking is that by keeping the test code simple, it won't look intimidating to newbs.

It might make sense to include a test that tests some of the generated classes in the project_root/python/ directory, both as working examples and to ensure all quickly projects begin life with 100% test coverage.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

It'd be nice to have 'run-tests' exit with a non-zero value if any test failed for ease of integration into an automated test run.

And do you know if python-distutils (or -extra) has support for finding and running a test suite? Would be good to make this suite match distutils' expectations.

Also... Maybe a good first test would be to call pylint on the project? There's an example of good pylint arguments in my branch that adds a pylint test to quickly itself: https://code.launchpad.net/~mterry/quickly/pylint/+merge/42501

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

Oh, but thanks! This is a great idea. :)

Revision history for this message
Tony Byrne (tony-badwolf) wrote :

Nice idea. The supplied bash script generates an warning when you quickly package so I pushed a new branch that uses "quickly test" instead. The supplied unittest did not refer to the user's project so I upgraded to actually test a trivial project property to "document" the linkage. Uses nosetest to automatically create the test suite.

https://code.launchpad.net/~tony-badwolf/quickly/project_tests

Revision history for this message
Michael Terry (mterry) wrote :

I'll mark this as rejected since we merged a different but similar branch. Thanks, Bryce!

Unmerged revisions

583. By Bryce Harrington

Add a simple stubbed-in unit test framework to the quickly templates

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'data/templates/ubuntu-application/project_root/run-tests'
2--- data/templates/ubuntu-application/project_root/run-tests 1970-01-01 00:00:00 +0000
3+++ data/templates/ubuntu-application/project_root/run-tests 2011-01-22 22:53:57 +0000
4@@ -0,0 +1,7 @@
5+#!/bin/bash
6+
7+for t in tests/test*; do
8+ echo $t
9+ python $t
10+ echo
11+done
12
13=== added directory 'data/templates/ubuntu-application/project_root/tests'
14=== added file 'data/templates/ubuntu-application/project_root/tests/test_example'
15--- data/templates/ubuntu-application/project_root/tests/test_example 1970-01-01 00:00:00 +0000
16+++ data/templates/ubuntu-application/project_root/tests/test_example 2011-01-22 22:53:57 +0000
17@@ -0,0 +1,19 @@
18+#!/usr/bin/python
19+
20+import sys
21+import os.path
22+import unittest
23+sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
24+
25+
26+class TestExample(unittest.TestCase):
27+ def setUp(self):
28+ self.something = 42
29+
30+ def test_something(self):
31+ my_value = 2 * 3 * 7
32+ self.assertEqual(self.something, my_value)
33+
34+if __name__ == '__main__':
35+ unittest.main()
36+

Subscribers

People subscribed via source and target branches