Merge lp:~jderose/microfiber/package into lp:microfiber

Proposed by Jason Gerard DeRose
Status: Merged
Merged at revision: 177
Proposed branch: lp:~jderose/microfiber/package
Merge into: lp:microfiber
Diff against target: 190 lines (+80/-29)
5 files modified
.bzrignore (+2/-2)
MANIFEST.in (+0/-1)
benchmark_microfiber.py (+6/-6)
microfiber/tests/run.py (+68/-0)
setup.py (+4/-20)
To merge this branch: bzr merge lp:~jderose/microfiber/package
Reviewer Review Type Date Requested Status
xzcvczx (community) master Approve
sarasfox (community) Approve
microfiber dev Pending
Review via email: mp+149742@code.launchpad.net

Description of the change

For details, see this bug:

https://bugs.launchpad.net/microfiber/+bug/1131007

Changes include:

* Moved microfiber.py to microfiber/__init__.py

* Moved test_microfiber.py to microfiber/tests/__init__.py

* Added microfiber.tests.run callable module

* Change `setup.py test` to use microfiber.tests.run.run_tests()

* setup.py now installs both the microfiber and microfiber.tests packages

* For fun, in benchmark use time.perf_counter() available in Python 3.3

To post a comment you must log in.
Revision history for this message
sarasfox (kevin-cloinger) wrote :

Nice I like the idea of moving the test new file. I don't see any thing ugly up out you got my thumbs up.

review: Approve
Revision history for this message
Jason Gerard DeRose (jderose) wrote :

Thanks!

Revision history for this message
xzcvczx (xzcvczx) wrote :

Looks good

review: Approve (master)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-09-01 10:13:07 +0000
3+++ .bzrignore 2013-02-21 02:50:28 +0000
4@@ -1,2 +1,2 @@
5-__pycache__
6-doc/_build/*
7+build/
8+doc/_build/
9
10=== modified file 'MANIFEST.in'
11--- MANIFEST.in 2011-09-23 20:45:13 +0000
12+++ MANIFEST.in 2013-02-21 02:50:28 +0000
13@@ -1,3 +1,2 @@
14 include COPYING COPYING.LESSER
15-include test_microfiber.py
16 include doc/*
17
18=== modified file 'benchmark_microfiber.py'
19--- benchmark_microfiber.py 2012-09-04 17:31:57 +0000
20+++ benchmark_microfiber.py 2013-02-21 02:50:28 +0000
21@@ -70,31 +70,31 @@
22 )
23
24 print(' Saving {} documents in db {!r}...'.format(count, name))
25-start = time.time()
26+start = time.perf_counter()
27 for _id in ids:
28 doc = dict(master)
29 doc['_id'] = _id
30 db.save(doc)
31 docs.append(doc)
32-elapsed = time.time() - start
33+elapsed = time.perf_counter() - start
34 total += elapsed
35 print(' Seconds: {:.2f}'.format(elapsed))
36 print(' Saves per second: {:.1f}'.format(count / elapsed))
37
38 print(' Getting {} documents from db {!r}...'.format(count, name))
39-start = time.time()
40+start = time.perf_counter()
41 for _id in ids:
42 db.get(_id)
43-elapsed = time.time() - start
44+elapsed = time.perf_counter() - start
45 total += elapsed
46 print(' Seconds: {:.2f}'.format(elapsed))
47 print(' Gets per second: {:.1f}'.format(count / elapsed))
48
49 print(' Deleting {} documents from db {!r}...'.format(count, name))
50-start = time.time()
51+start = time.perf_counter()
52 for doc in docs:
53 db.delete(doc['_id'], rev=doc['_rev'])
54-elapsed = time.time() - start
55+elapsed = time.perf_counter() - start
56 total += elapsed
57 print(' Seconds: {:.2f}'.format(elapsed))
58 print(' Deletes per second: {:.1f}'.format(count / elapsed))
59
60=== added directory 'microfiber'
61=== renamed file 'microfiber.py' => 'microfiber/__init__.py'
62=== added directory 'microfiber/tests'
63=== renamed file 'test_microfiber.py' => 'microfiber/tests/__init__.py'
64=== added file 'microfiber/tests/run.py'
65--- microfiber/tests/run.py 1970-01-01 00:00:00 +0000
66+++ microfiber/tests/run.py 2013-02-21 02:50:28 +0000
67@@ -0,0 +1,68 @@
68+# microfiber: fabric for a lightweight Couch
69+# Copyright (C) 2013 Novacut Inc
70+#
71+# This file is part of `microfiber`.
72+#
73+# `microfiber` is free software: you can redistribute it and/or modify it under
74+# the terms of the GNU Lesser General Public License as published by the Free
75+# Software Foundation, either version 3 of the License, or (at your option) any
76+# later version.
77+#
78+# `microfiber` is distributed in the hope that it will be useful, but WITHOUT
79+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
80+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
81+# details.
82+#
83+# You should have received a copy of the GNU Lesser General Public License along
84+# with `microfiber`. If not, see <http://www.gnu.org/licenses/>.
85+#
86+# Authors:
87+# Jason Gerard DeRose <jderose@novacut.com>
88+#
89+
90+"""
91+Run the `microfiber` unit tests.
92+
93+From the command line, run like this::
94+
95+ $ python3 -m microfiber.tests.run
96+"""
97+
98+import sys
99+from os import path
100+from unittest import TestLoader, TextTestRunner
101+from doctest import DocTestSuite
102+
103+import microfiber
104+
105+
106+pynames = (
107+ 'microfiber',
108+ 'microfiber.tests',
109+)
110+
111+
112+def run_tests():
113+ # Add unit-tests:
114+ loader = TestLoader()
115+ suite = loader.loadTestsFromNames(pynames)
116+
117+ # Add doc-tests:
118+ for name in pynames:
119+ suite.addTest(DocTestSuite(name))
120+
121+ # Run the tests:
122+ runner = TextTestRunner(verbosity=2)
123+ result = runner.run(suite)
124+ success = result.wasSuccessful()
125+ print(
126+ 'microfiber: {!r}'.format(path.abspath(microfiber.__file__)),
127+ file=sys.stderr
128+ )
129+ print('-' * 70, file=sys.stderr)
130+ return result.wasSuccessful()
131+
132+
133+if __name__ == '__main__':
134+ if not run_tests():
135+ raise SystemExit('2')
136
137=== modified file 'setup.py'
138--- setup.py 2013-02-12 08:33:52 +0000
139+++ setup.py 2013-02-21 02:50:28 +0000
140@@ -35,11 +35,10 @@
141
142 from distutils.core import setup
143 from distutils.cmd import Command
144-from unittest import TestLoader, TextTestRunner
145-from doctest import DocTestSuite
146 import os
147
148 import microfiber
149+from microfiber.tests.run import run_tests
150
151
152 class Test(Command):
153@@ -58,27 +57,12 @@
154 pass
155
156 def run(self):
157- # Possibly set environ variables for live test:
158 if self.no_live:
159 os.environ['MICROFIBER_TEST_NO_LIVE'] = 'true'
160 if self.skip_slow:
161 os.environ['MICROFIBER_TEST_SKIP_SLOW'] = 'true'
162-
163- pynames = ['microfiber', 'test_microfiber']
164-
165- # Add unit-tests:
166- loader = TestLoader()
167- suite = loader.loadTestsFromNames(pynames)
168-
169- # Add doc-tests:
170- for name in pynames:
171- suite.addTest(DocTestSuite(name))
172-
173- # Run the tests:
174- runner = TextTestRunner(verbosity=2)
175- result = runner.run(suite)
176- if not result.wasSuccessful():
177- raise SystemExit(2)
178+ if not run_tests():
179+ raise SystemExit('2')
180
181
182 setup(
183@@ -89,6 +73,6 @@
184 author='Jason Gerard DeRose',
185 author_email='jderose@novacut.com',
186 license='LGPLv3+',
187- py_modules=['microfiber'],
188+ packages=['microfiber', 'microfiber.tests'],
189 cmdclass={'test': Test},
190 )

Subscribers

People subscribed via source and target branches