Permalink
Browse files

switching to unittest2 & newer assert functions

  • Loading branch information...
1 parent be22b4b commit 40bf782b8b9862306d11223b09192d240b0cd4bf @BigBlueHat BigBlueHat committed Dec 16, 2013
Showing with 52 additions and 45 deletions.
  1. +1 −1 setup.py
  2. +50 −43 tests/test_cli.py
  3. +1 −1 tests/test_ignores.py
View
@@ -152,7 +152,7 @@ def main():
author_email='benoitc@e-engura.org',
description='Standalone CouchDB Application Development Made Simple.',
long_description=long_description,
- tests_require = ['nose', 'coverage'],
+ tests_require = ['unittest2', 'nose', 'coverage'],
test_suite="tests",
keywords='couchdb couchapp',
platforms=['any'],
View
@@ -10,7 +10,7 @@
import tempfile
import shutil
import sys
-import unittest
+import unittest2 as unittest
from couchapp.errors import ResourceNotFound
from couchapp.client import Database
@@ -59,8 +59,9 @@ def testGenerate(self):
self.assertTrue(os.path.isdir(os.path.join(appdir, '_attachments')))
self.assertTrue(os.path.isfile(os.path.join(appdir, '_attachments',
'index.html')))
- self.assert_(os.path.isfile(os.path.join(self.app_dir, '_attachments',
- 'style', 'main.css')))
+ self.assertTrue(os.path.isfile(os.path.join(self.app_dir,
+ '_attachments',
+ 'style', 'main.css')))
self.assertTrue(os.path.isdir(os.path.join(appdir, 'views')))
self.assertTrue(os.path.isdir(os.path.join(appdir, 'shows')))
self.assertTrue(os.path.isdir(os.path.join(appdir, 'lists')))
@@ -76,34 +77,37 @@ def testPush(self):
design_doc = self.db.open_doc('_design/my-app')
except ResourceNotFound:
pass
- self.assert_(design_doc is not None)
+ self.assertIsNotNone(design_doc)
# should create view
- self.assert_('function' in design_doc['views']['example']['map'])
+ self.assertIn('function', design_doc['views']['example']['map'])
# should use macros
- self.assert_('stddev' in design_doc['views']['example']['map'])
- self.assert_('ejohn.org' in design_doc['shows']['example-show'])
- self.assert_('included by foo.js' in design_doc['shows']['example-show'])
+ self.assertIn('stddev', design_doc['views']['example']['map'])
+ self.assertIn('ejohn.org', design_doc['shows']['example-show'])
+ self.assertIn('included by foo.js',
+ design_doc['shows']['example-show'])
# should create index
- self.assert_(design_doc['_attachments']['index.html']['content_type'] == 'text/html')
+ content_type = design_doc['_attachments']['index.html']['content_type']
+ self.assertEqual(content_type, 'text/html')
# should create manifest
- self.assert_('foo/' in design_doc['couchapp']['manifest'])
+ self.assertIn('foo/', design_doc['couchapp']['manifest'])
# should push and macro the doc shows
- self.assert_('Generated CouchApp Form Template' in design_doc['shows']['example-show'])
+ self.assertIn('Generated CouchApp Form Template',
+ design_doc['shows']['example-show'])
# should push and macro the view lists
- self.assert_('Test XML Feed' in design_doc['lists']['feed'])
+ self.assertIn('Test XML Feed', design_doc['lists']['feed'])
# should allow deeper includes
- self.assertFalse('"helpers"' in design_doc['shows']['example-show'])
+ self.assertNotIn('"helpers"', design_doc['shows']['example-show'])
# deep require macros
- self.assertFalse('"template"' in design_doc['shows']['example-show'])
- self.assert_('Resig' in design_doc['shows']['example-show'])
+ self.assertNotIn('"template"', design_doc['shows']['example-show'])
+ self.assertIn('Resig', design_doc['shows']['example-show'])
def testPushNoAtomic(self):
self._make_testapp()
@@ -116,36 +120,38 @@ def testPushNoAtomic(self):
design_doc = self.db.open_doc('_design/my-app')
except ResourceNotFound:
pass
- self.assert_(design_doc is not None)
+ self.assertIsNotNone(design_doc)
# there are 3 revisions (1 doc creation + 2 attachments)
- self.assert_(design_doc['_rev'].startswith('3-'))
+ self.assertTrue(design_doc['_rev'].startswith('3-'))
# should create view
- self.assert_('function' in design_doc['views']['example']['map'])
+ self.assertIn('function', design_doc['views']['example']['map'])
# should use macros
- self.assert_('stddev' in design_doc['views']['example']['map'])
- self.assert_('ejohn.org' in design_doc['shows']['example-show'])
+ self.assertIn('stddev', design_doc['views']['example']['map'])
+ self.assertIn('ejohn.org', design_doc['shows']['example-show'])
# should create index
- self.assert_(design_doc['_attachments']['index.html']['content_type'] == 'text/html')
+ content_type = design_doc['_attachments']['index.html']['content_type']
+ self.assertEqual(content_type, 'text/html')
# should create manifest
- self.assert_('foo/' in design_doc['couchapp']['manifest'])
+ self.assertIn('foo/', design_doc['couchapp']['manifest'])
# should push and macro the doc shows
- self.assert_('Generated CouchApp Form Template' in design_doc['shows']['example-show'])
+ self.assertIn('Generated CouchApp Form Template',
+ design_doc['shows']['example-show'])
# should push and macro the view lists
- self.assert_('Test XML Feed' in design_doc['lists']['feed'])
+ self.assertIn('Test XML Feed', design_doc['lists']['feed'])
# should allow deeper includes
- self.assertFalse('"helpers"' in design_doc['shows']['example-show'])
+ self.assertNotIn('"helpers"', design_doc['shows']['example-show'])
# deep require macros
- self.assertFalse('"template"' in design_doc['shows']['example-show'])
- self.assert_('Resig' in design_doc['shows']['example-show'])
+ self.assertNotIn('"template"', design_doc['shows']['example-show'])
+ self.assertIn('Resig', design_doc['shows']['example-show'])
def testClone(self):
self._make_testapp()
@@ -163,17 +169,17 @@ def testClone(self):
app_dir))
# should create .couchapprc
- self.assert_(os.path.isfile(os.path.join(app_dir, ".couchapprc")))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir, ".couchapprc")))
# should clone the views
- self.assert_(os.path.isdir(os.path.join(app_dir, "views")))
+ self.assertTrue(os.path.isdir(os.path.join(app_dir, "views")))
# should create foo/bar.txt file
- self.assert_(os.path.isfile(os.path.join(app_dir, 'foo/bar.txt')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir, 'foo/bar.txt')))
# should create lib/helpers/math.js file
- self.assert_(os.path.isfile(os.path.join(app_dir,
- 'lib/helpers/math.js')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir,
+ 'lib/helpers/math.js')))
# should work when design doc is edited manually
design_doc['test.txt'] = "essai"
@@ -186,7 +192,7 @@ def testClone(self):
% (self.cmd,
"http://127.0.0.1:5984/couchapp-test/_design/my-app",
app_dir))
- self.assert_(os.path.isfile(os.path.join(app_dir, 'test.txt')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir, 'test.txt')))
# should work when a view is added manually
design_doc["views"]["more"] = {"map":
@@ -200,8 +206,8 @@ def testClone(self):
% (self.cmd,
"http://127.0.0.1:5984/couchapp-test/_design/my-app",
app_dir))
- self.assert_(os.path.isfile(os.path.join(app_dir,
- 'views/example/map.js')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir,
+ 'views/example/map.js')))
# should work without manifest
del design_doc['couchapp']['manifest']
@@ -212,14 +218,15 @@ def testClone(self):
% (self.cmd,
"http://127.0.0.1:5984/couchapp-test/_design/my-app",
app_dir))
- self.assert_(os.path.isfile(os.path.join(app_dir,
- 'views/example/map.js')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir,
+ 'views/example/map.js')))
# should create foo/bar without manifest
- self.assert_(os.path.isfile(os.path.join(app_dir, 'foo/bar')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir, 'foo/bar')))
# should create lib/helpers.json without manifest
- self.assert_(os.path.isfile(os.path.join(app_dir, 'lib/helpers.json')))
+ self.assertTrue(os.path.isfile(os.path.join(app_dir,
+ 'lib/helpers.json')))
def testPushApps(self):
os.chdir(self.tempdir)
@@ -237,8 +244,8 @@ def testPushApps(self):
% self.cmd)
alldocs = self.db.all_docs()['rows']
- self.assert_(len(alldocs) == 2)
- self.assert_('_design/app1' == alldocs[0]['id'])
+ self.assertEqual(len(alldocs), 2)
+ self.assertEqual('_design/app1', alldocs[0]['id'])
def testPushDocs(self):
os.chdir(self.tempdir)
@@ -257,9 +264,9 @@ def testPushDocs(self):
alldocs = self.db.all_docs()['rows']
- self.assert_(len(alldocs) == 2)
+ self.assertEqual(len(alldocs), 2)
- self.assert_('_design/app1' == alldocs[0]['id'])
+ self.assertEqual('_design/app1', alldocs[0]['id'])
def _make_testapp(self):
testapp_path = os.path.join(os.path.dirname(__file__), 'testapp')
View
@@ -15,7 +15,7 @@
# limitations under the License.
#
-import unittest
+import unittest2 as unittest
import tempfile
import os
from shutil import rmtree

0 comments on commit 40bf782

Please sign in to comment.