From 8522ac55af7cb9ba7f875db4558e5185e85dcb0a Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 08:42:53 +0000 Subject: [PATCH 1/7] Run calibre.library tests - follow convention, add a find_tests, tests method to calibre.library.test. Add calibre.library to the list in setup/test.py - sort some imports - add .cache to .gitignore --- .gitignore | 1 + setup/test.py | 5 ++++- src/calibre/library/test.py | 13 +++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 69b7077498..9b364e6b05 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .bzr .bzrignore .build-cache +.cache src/calibre/plugins resources/images.qrc manual/generated diff --git a/setup/test.py b/setup/test.py index 71efa6fe70..8483f127d5 100644 --- a/setup/test.py +++ b/setup/test.py @@ -8,7 +8,7 @@ import unittest from setup import Command -TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc'.split()) +TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc library'.split()) def find_tests(which_tests=None): ans = [] @@ -64,6 +64,9 @@ def find_tests(which_tests=None): a(find_tests()) from calibre.utils.shared_file import find_tests a(find_tests()) + if ok('library'): + from calibre.library.test import find_tests + a(find_tests()) tests = unittest.TestSuite(ans) return tests diff --git a/src/calibre/library/test.py b/src/calibre/library/test.py index f1563fb996..ebeb27818a 100644 --- a/src/calibre/library/test.py +++ b/src/calibre/library/test.py @@ -10,10 +10,10 @@ Unit tests for database layer. import sys, unittest, os, cStringIO from itertools import repeat -from calibre.ptempfile import PersistentTemporaryDirectory -from calibre.library.database2 import LibraryDatabase2 from calibre.ebooks.metadata import MetaInformation - +from calibre.library.database2 import LibraryDatabase2 +from calibre.ptempfile import PersistentTemporaryDirectory +from calibre.utils.run_tests import find_tests_in_dir, run_tests class DBTest(unittest.TestCase): @@ -89,12 +89,13 @@ class DBTest(unittest.TestCase): self.assertEqual(self.db.rating(0), 3) -def suite(): - return unittest.TestLoader().loadTestsFromTestCase(DBTest) +def find_tests(): + base = os.path.dirname(os.path.abspath(__file__)) + return find_tests_in_dir(base) def test(): - unittest.TextTestRunner(verbosity=2).run(suite()) + run_tests(find_tests()) def main(args=sys.argv): From a517cec2cdbb5547129cc82d2ed8c071b5c7e460 Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 09:51:53 +0000 Subject: [PATCH 2/7] Fix calibre.library.test.DBTest - fix testSorting by making the author_sort field on the test data unique. - make tests less brittle by declaratively defining the data to be compared by testSorting --- src/calibre/library/test.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/calibre/library/test.py b/src/calibre/library/test.py index ebeb27818a..b6b43a44ca 100644 --- a/src/calibre/library/test.py +++ b/src/calibre/library/test.py @@ -15,33 +15,40 @@ from calibre.library.database2 import LibraryDatabase2 from calibre.ptempfile import PersistentTemporaryDirectory from calibre.utils.run_tests import find_tests_in_dir, run_tests + class DBTest(unittest.TestCase): img = '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00d\x00d\x00\x00\xff\xdb\x00C\x00\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13\x14\x1a\x15\x11\x11\x18!\x18\x1a\x1d\x1d\x1f\x1f\x1f\x13\x17"$"\x1e$\x1c\x1e\x1f\x1e\xff\xdb\x00C\x01\x05\x05\x05\x07\x06\x07\x0e\x08\x08\x0e\x1e\x14\x11\x14\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\xff\xc0\x00\x11\x08\x00\x01\x00\x01\x03\x01\x11\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x14\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00p\xf9+\xff\xd9' # noqa def setUp(self): - self.tdir = PersistentTemporaryDirectory('_calibre_dbtest') - self.db = LibraryDatabase2(self.tdir) + self.tdir = PersistentTemporaryDirectory('_calibre_dbtest') + self.db = LibraryDatabase2(self.tdir) f = open(os.path.join(self.tdir, 'test.txt'), 'w+b') f.write('test') paths = list(repeat(f, 3)) formats = list(repeat('txt', 3)) - m1 = MetaInformation('Test Ebook 1', ['Test Author 1']) + + # sorted tuple of tuples of (author-sort author name, full author name) + self.authors = sorted((('as1', 'Test Author 1'), ('as2', 'Test Author 2'))) + self.ratings = sorted((3, 2), reverse=True) + + m1 = MetaInformation('Test Ebook 1', [self.authors[0][1]]) m1.tags = ['tag1', 'tag2'] m1.publisher = 'Test Publisher 1' - m1.rating = 2 + m1.rating = self.ratings[1] m1.series = 'Test Series 1' m1.series_index = 3 - m1.author_sort = 'as1' + m1.author_sort = self.authors[0][0] m1.isbn = 'isbn1' m1.cover_data = ('jpg', self.img) - m2 = MetaInformation('Test Ebook 2', ['Test Author 2']) + + m2 = MetaInformation('Test Ebook 2', [self.authors[1][1]]) m2.tags = ['tag3', 'tag4'] m2.publisher = 'Test Publisher 2' - m2.rating = 3 + m2.rating = self.ratings[0] m2.series = 'Test Series 2' m2.series_index = 1 - m2.author_sort = 'as1' + m2.author_sort = self.authors[1][0] m2.isbn = 'isbn1' self.db.add_books(paths, formats, [m1, m2, m2], add_duplicates=True) self.m1, self.m2 = m1, m2 @@ -71,7 +78,8 @@ class DBTest(unittest.TestCase): def testMetadata(self): self.db.refresh('timestamp', True) - for x in ('title', 'author_sort', 'series', 'publisher', 'isbn', 'series_index', 'rating'): + for x in ('title', 'author_sort', 'series', 'publisher', 'isbn', + 'series_index', 'rating'): val = 3 if x in ['rating', 'series_index'] else 'dummy' getattr(self.db, 'set_'+x)(3, val) self.db.refresh_ids([3]) @@ -84,9 +92,9 @@ class DBTest(unittest.TestCase): def testSorting(self): self.db.sort('authors', True) - self.assertEqual(self.db.authors(0), 'Test Author 1') + self.assertEqual(self.db.authors(0), self.authors[0][1]) self.db.sort('rating', False) - self.assertEqual(self.db.rating(0), 3) + self.assertEqual(self.db.rating(0), self.ratings[0]) def find_tests(): @@ -98,9 +106,10 @@ def test(): run_tests(find_tests()) -def main(args=sys.argv): +def main(): test() return 0 + if __name__ == '__main__': sys.exit(main()) From fd703171716b1cc40904952461622ea7c0f70fb0 Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 11:05:16 +0000 Subject: [PATCH 3/7] c.library.cli: extract check_library printing - extract printing/formatting logic from calibre.library.cli.command_check_library - add tests asserting current behaviour --- src/calibre/library/cli.py | 28 +++++---- src/calibre/library/test_cli.py | 101 ++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 src/calibre/library/test_cli.py diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index 8d7adbbf00..f77afda15b 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -1362,18 +1362,6 @@ def command_check_library(args, dbpath): else: exts = [f.strip() for f in opts.exts.split(',') if f.strip()] - def print_one(checker, check): - attr = check[0] - list = getattr(checker, attr, None) - if list is None: - return - if opts.csv: - for i in list: - print check[1] + ',' + i[0] + ',' + i[1] - else: - print check[1] - for i in list: - print ' %-40.40s - %-40.40s'%(i[0], i[1]) if not LibraryDatabase.exists_at(dbpath): prints('No library found at', dbpath, file=sys.stderr) @@ -1383,7 +1371,21 @@ def command_check_library(args, dbpath): checker = CheckLibrary(dbpath, db) checker.scan_library(names, exts) for check in checks: - print_one(checker, check) + _print_check_library_results(checker, check) + + +def _print_check_library_results(checker, check, opts): + attr = check[0] + list = getattr(checker, attr, None) + if list is None: + return + if opts.csv: + for i in list: + print check[1] + ',' + i[0] + ',' + i[1] + else: + print check[1] + for i in list: + print ' %-40.40s - %-40.40s'%(i[0], i[1]) def restore_database_option_parser(): diff --git a/src/calibre/library/test_cli.py b/src/calibre/library/test_cli.py new file mode 100644 index 0000000000..4b81de081d --- /dev/null +++ b/src/calibre/library/test_cli.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python2 +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import (unicode_literals, division, absolute_import, + print_function) + +__license__ = 'GPL v3' +__docformat__ = 'restructuredtext en' + +''' +Test the CLI of the calibre database management tool +''' +import csv, sys +import unittest +from StringIO import StringIO + +from mock import Mock, patch + +from calibre.library.check_library import CheckLibrary +from calibre.library.cli import _print_check_library_results + + +class PrintCheckLibraryResultsTest(unittest.TestCase): + """ + Asserts the format of the output to the CLI to avoid regressions + """ + check_machine_name = 'dummy_check' + check_human_name = 'Dummy Check' + check = (check_machine_name, check_human_name, True, False) + + @patch('sys.stdout', new_callable=StringIO) + def test_prints_nothing_if_no_errors(self, mock_stdout): + checker = Mock(name='checker', spec=CheckLibrary) + setattr(checker, self.check_machine_name, None) + opts = Mock() + + opts.csv = False + _print_check_library_results(checker, self.check, opts) + self.assertEqual(mock_stdout.getvalue(), '') + + opts.csv = True + _print_check_library_results(checker, self.check, opts) + self.assertEqual(mock_stdout.getvalue(), '') + + @patch('sys.stdout', new_callable=StringIO) + def test_human_readable_output(self, mock_stdout): + """ + Basic check of the human-readable output. + + Does not test: the full line format, truncation + """ + checker = Mock(name='checker', speck=CheckLibrary) + data = [['first', 'second']] + opts = Mock() + opts.csv = False + setattr(checker, self.check_machine_name, data) + _print_check_library_results(checker, self.check, opts) + + result = mock_stdout.getvalue().split('\n') + self.assertEqual(len(result), len(data)+2) + self.assertEqual(result[0], self.check_human_name) + + result_first = result[1].split('-')[0].strip() + result_second = result[1].split('-')[1].strip() + + self.assertEqual(result_first, 'first') + self.assertEqual(result_second, 'second') + + self.assertEqual(result[-1], '') + + @patch('sys.stdout', new_callable=StringIO) + def test_basic_csv_output(self, mock_stdout): + """ + Test simple csv output + """ + checker = Mock(name='checker', speck=CheckLibrary) + data = [['first', 'second']] + opts = Mock() + opts.csv = True + setattr(checker, self.check_machine_name, data) + _print_check_library_results(checker, self.check, opts) + + result = mock_stdout.getvalue().split('\n') + parsed_result = [l for l in csv.reader(result) if l] + self.assertEqual(parsed_result, [[self.check_human_name, data[0][0], data[0][1]]]) + + @patch('sys.stdout', new_callable=StringIO) + def test_escaped_csv_output(self, mock_stdout): + """ + Test more complex csv output + """ + raise unittest.SkipTest('This test fails, as csv output does not currently escape') + checker = Mock(name='checker', speck=CheckLibrary) + data = [['I, Caesar', 'second']] + opts = Mock() + opts.csv = True + setattr(checker, self.check_machine_name, data) + _print_check_library_results(checker, self.check, opts) + + result = mock_stdout.getvalue().split('\n') + parsed_result = [l for l in csv.reader(result) if l] + self.assertEqual(parsed_result, [[self.check_human_name, data[0][0], data[0][1]]]) From 0dd2c54510d4dd9ac762f445bb99ea77c5c9e376 Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 11:19:18 +0000 Subject: [PATCH 4/7] c.library.cli: use csv module for check_library - use the builtin csv module for check_library output - enable the comma-escaping test in test_cli --- src/calibre/library/cli.py | 10 +++++++--- src/calibre/library/test_cli.py | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index f77afda15b..ca89c6fa1f 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en' Command line interface to the calibre database. ''' -import sys, os, cStringIO, re +import cStringIO, csv, os, re, sys import unicodedata from textwrap import TextWrapper from optparse import OptionValueError, OptionGroup @@ -1379,9 +1379,13 @@ def _print_check_library_results(checker, check, opts): list = getattr(checker, attr, None) if list is None: return + if opts.csv: - for i in list: - print check[1] + ',' + i[0] + ',' + i[1] + to_output = [(check[1], i[0], i[1]) for i in list] + csv_print = csv.writer(sys.stdout) + for line in to_output: + csv_print.writerow(line) + else: print check[1] for i in list: diff --git a/src/calibre/library/test_cli.py b/src/calibre/library/test_cli.py index 4b81de081d..be7c55f179 100644 --- a/src/calibre/library/test_cli.py +++ b/src/calibre/library/test_cli.py @@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en' ''' Test the CLI of the calibre database management tool ''' -import csv, sys +import csv import unittest from StringIO import StringIO @@ -88,7 +88,6 @@ class PrintCheckLibraryResultsTest(unittest.TestCase): """ Test more complex csv output """ - raise unittest.SkipTest('This test fails, as csv output does not currently escape') checker = Mock(name='checker', speck=CheckLibrary) data = [['I, Caesar', 'second']] opts = Mock() From a6093e8cac7bf4f11a5952b692fa4bb318f98567 Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 11:28:01 +0000 Subject: [PATCH 5/7] rm c.library.test Per comment on https://github.com/kovidgoyal/calibre/pull/592, this test module is unnecessary. --- setup/test.py | 4 +- src/calibre/library/test.py | 115 ------------------------------------ 2 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 src/calibre/library/test.py diff --git a/setup/test.py b/setup/test.py index 8483f127d5..b7ac4dd1c5 100644 --- a/setup/test.py +++ b/setup/test.py @@ -65,12 +65,12 @@ def find_tests(which_tests=None): from calibre.utils.shared_file import find_tests a(find_tests()) if ok('library'): - from calibre.library.test import find_tests - a(find_tests()) + a(unittest.TestLoader().discover('src/calibre/library')) tests = unittest.TestSuite(ans) return tests + class Test(Command): description = 'Run the calibre test suite' diff --git a/src/calibre/library/test.py b/src/calibre/library/test.py deleted file mode 100644 index b6b43a44ca..0000000000 --- a/src/calibre/library/test.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python2 -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' -__docformat__ = 'restructuredtext en' - -''' -Unit tests for database layer. -''' - -import sys, unittest, os, cStringIO -from itertools import repeat - -from calibre.ebooks.metadata import MetaInformation -from calibre.library.database2 import LibraryDatabase2 -from calibre.ptempfile import PersistentTemporaryDirectory -from calibre.utils.run_tests import find_tests_in_dir, run_tests - - -class DBTest(unittest.TestCase): - - img = '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00d\x00d\x00\x00\xff\xdb\x00C\x00\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c\x08\x07\x07\x07\x07\x0f\x0b\x0b\t\x0c\x11\x0f\x12\x12\x11\x0f\x11\x11\x13\x16\x1c\x17\x13\x14\x1a\x15\x11\x11\x18!\x18\x1a\x1d\x1d\x1f\x1f\x1f\x13\x17"$"\x1e$\x1c\x1e\x1f\x1e\xff\xdb\x00C\x01\x05\x05\x05\x07\x06\x07\x0e\x08\x08\x0e\x1e\x14\x11\x14\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\xff\xc0\x00\x11\x08\x00\x01\x00\x01\x03\x01\x11\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x14\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00p\xf9+\xff\xd9' # noqa - - def setUp(self): - self.tdir = PersistentTemporaryDirectory('_calibre_dbtest') - self.db = LibraryDatabase2(self.tdir) - f = open(os.path.join(self.tdir, 'test.txt'), 'w+b') - f.write('test') - paths = list(repeat(f, 3)) - formats = list(repeat('txt', 3)) - - # sorted tuple of tuples of (author-sort author name, full author name) - self.authors = sorted((('as1', 'Test Author 1'), ('as2', 'Test Author 2'))) - self.ratings = sorted((3, 2), reverse=True) - - m1 = MetaInformation('Test Ebook 1', [self.authors[0][1]]) - m1.tags = ['tag1', 'tag2'] - m1.publisher = 'Test Publisher 1' - m1.rating = self.ratings[1] - m1.series = 'Test Series 1' - m1.series_index = 3 - m1.author_sort = self.authors[0][0] - m1.isbn = 'isbn1' - m1.cover_data = ('jpg', self.img) - - m2 = MetaInformation('Test Ebook 2', [self.authors[1][1]]) - m2.tags = ['tag3', 'tag4'] - m2.publisher = 'Test Publisher 2' - m2.rating = self.ratings[0] - m2.series = 'Test Series 2' - m2.series_index = 1 - m2.author_sort = self.authors[1][0] - m2.isbn = 'isbn1' - self.db.add_books(paths, formats, [m1, m2, m2], add_duplicates=True) - self.m1, self.m2 = m1, m2 - - def testAdding(self): - m1, m2 = self.db.get_metadata(1, True), self.db.get_metadata(2, True) - for p in ('title', 'authors', 'publisher', 'rating', 'series', - 'series_index', 'author_sort', 'isbn', 'tags'): - - def ga(mi, p): - val = getattr(mi, p) - if isinstance(val, list): - val = set(val) - return val - - self.assertEqual(ga(self.m1, p), ga(m1, p)) - self.assertEqual(ga(self.m2, p), ga(m2, p)) - - self.assertEqual(self.db.format(1, 'txt', index_is_id=True), 'test') - self.assertEqual(self.db.formats(1, index_is_id=True), 'TXT') - self.db.add_format(1, 'html', cStringIO.StringIO(''), index_is_id=True) - self.assertEqual(self.db.formats(1, index_is_id=True), 'HTML,TXT') - self.db.remove_format(1, 'html', index_is_id=True) - self.assertEqual(self.db.formats(1, index_is_id=True), 'TXT') - self.assertNotEqual(self.db.cover(1, index_is_id=True), None) - self.assertEqual(self.db.cover(2, index_is_id=True), None) - - def testMetadata(self): - self.db.refresh('timestamp', True) - for x in ('title', 'author_sort', 'series', 'publisher', 'isbn', - 'series_index', 'rating'): - val = 3 if x in ['rating', 'series_index'] else 'dummy' - getattr(self.db, 'set_'+x)(3, val) - self.db.refresh_ids([3]) - self.assertEqual(getattr(self.db, x)(2), val) - - self.db.set_authors(3, ['new auth']) - self.db.refresh_ids([3]) - self.assertEqual('new auth', self.db.authors(2)) - self.assertEqual(self.db.format(3, 'txt', index_is_id=True), 'test') - - def testSorting(self): - self.db.sort('authors', True) - self.assertEqual(self.db.authors(0), self.authors[0][1]) - self.db.sort('rating', False) - self.assertEqual(self.db.rating(0), self.ratings[0]) - - -def find_tests(): - base = os.path.dirname(os.path.abspath(__file__)) - return find_tests_in_dir(base) - - -def test(): - run_tests(find_tests()) - - -def main(): - test() - return 0 - - -if __name__ == '__main__': - sys.exit(main()) From 3c4d2391856ac4e5e8447b806f75fc84cb6a3edf Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 11:48:32 +0000 Subject: [PATCH 6/7] bugfix: pass opts to print*check_library* --- src/calibre/library/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py index ca89c6fa1f..e80766b775 100644 --- a/src/calibre/library/cli.py +++ b/src/calibre/library/cli.py @@ -1371,7 +1371,7 @@ def command_check_library(args, dbpath): checker = CheckLibrary(dbpath, db) checker.scan_library(names, exts) for check in checks: - _print_check_library_results(checker, check) + _print_check_library_results(checker, check, opts) def _print_check_library_results(checker, check, opts): From 932430cd23a921dff687e5c30f526c4cbdfc9bc6 Mon Sep 17 00:00:00 2001 From: James Broadhead Date: Mon, 5 Dec 2016 12:03:31 +0000 Subject: [PATCH 7/7] Install mock on travis --- .travis.yml | 3 +++ appveyor.yml | 6 ++++-- requirements.txt | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 782c598f83..17bffbd05c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,8 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo mkdir -p $SWBASE && sudo chown $USER $SWBASE; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl https://download.calibre-ebook.com/travis/sw-osx.tar.bz2 | tar xj -C $SWBASE; fi - npm install --no-optional rapydscript-ng && echo $PATH && which rapydscript && rapydscript --version + - python $SW/bin/easy_install --user "pip==9.0.1" + - pip install --user -r requirements.txt - python setup.py bootstrap --ephemeral + script: python setup.py test diff --git a/appveyor.yml b/appveyor.yml index 6c18c61e53..4d8531fd7f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,7 @@ os: Visual Studio 2015 clone_folder: C:\calibre clone_depth: 5 branches: - only: + only: - vs2015 cache: @@ -19,7 +19,9 @@ platform: - x64 before_build: - - C:\Python35-x64\python.exe setup/win-ci.py sw + - C:\Python35-x64\python.exe setup/win-ci.py sw + - C:\sw\private\python\easy_install.exe --user "pip==9.0.1" + - C:\sw\private\python\pip install --user -r requirements.txt build_script: - C:\sw\private\python\python.exe setup/win-ci.py build diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..ade8b82800 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# Note, this file is work-in-progress, and is partial only. +mock==2.0.0