| http://wiki.spyderlib.googlecode.com/hg/Buttons/logo-mini.png | -||||||||
| [http://code.google.com/p/spyderlib http://wiki.spyderlib.googlecode.com/hg/Buttons/home.png] | -[http://code.google.com/p/spyderlib/downloads/list http://wiki.spyderlib.googlecode.com/hg/Buttons/download.png] | -[http://code.google.com/p/spyderlib/wiki/Features http://wiki.spyderlib.googlecode.com/hg/Buttons/features.png] | -[http://code.google.com/p/spyderlib/wiki/Screenshots http://wiki.spyderlib.googlecode.com/hg/Buttons/screenshots.png] | -[http://packages.python.org/spyder/ http://wiki.spyderlib.googlecode.com/hg/Buttons/docs.png] | -[http://code.google.com/p/spyderlib/wiki/Roadmap http://wiki.spyderlib.googlecode.com/hg/Buttons/roadmap.png] | -[http://code.google.com/p/spyderlib/wiki/Support http://wiki.spyderlib.googlecode.com/hg/Buttons/support.png] | -[http://code.google.com/p/spyderlib/wiki/Development http://wiki.spyderlib.googlecode.com/hg/Buttons/development_sel.png] | -[http://spyder-ide.blogspot.com http://wiki.spyderlib.googlecode.com/hg/Buttons/blog.png] | -
| http://wiki.spyderlib.googlecode.com/hg/Buttons/logo-mini.png | -||||||||
| [http://code.google.com/p/spyderlib http://wiki.spyderlib.googlecode.com/hg/Buttons/home.png] | -[http://code.google.com/p/spyderlib/downloads/list http://wiki.spyderlib.googlecode.com/hg/Buttons/download.png] | -[http://code.google.com/p/spyderlib/wiki/Features http://wiki.spyderlib.googlecode.com/hg/Buttons/features.png] | -[http://code.google.com/p/spyderlib/wiki/Screenshots http://wiki.spyderlib.googlecode.com/hg/Buttons/screenshots.png] | -[http://packages.python.org/spyder/ http://wiki.spyderlib.googlecode.com/hg/Buttons/docs.png] | -[http://code.google.com/p/spyderlib/wiki/Roadmap http://wiki.spyderlib.googlecode.com/hg/Buttons/roadmap.png] | -[http://code.google.com/p/spyderlib/wiki/Support http://wiki.spyderlib.googlecode.com/hg/Buttons/support.png] | -[http://code.google.com/p/spyderlib/wiki/Development http://wiki.spyderlib.googlecode.com/hg/Buttons/development_sel.png] | -[http://spyder-ide.blogspot.com http://wiki.spyderlib.googlecode.com/hg/Buttons/blog.png] | -
Download upload.py, a simple tool for -+
Download upload.py, a simple tool for - uploading diffs from a version control system to the codereview app.
- -Usage summary:
-y
\ No newline at end of file
diff --git a/tests/data/failing/non-empty-patch-for-empty-file.diff b/tests/data/failing/non-empty-patch-for-empty-file.diff
deleted file mode 100644
index 8efc328..0000000
--- a/tests/data/failing/non-empty-patch-for-empty-file.diff
+++ /dev/null
@@ -1,14 +0,0 @@
-Index: upload.py
-===================================================================
---- upload.py (revision 623)
-+++ upload.py (working copy)
-@@ -393,6 +393,9 @@
- ## elif e.code >= 500 and e.code < 600:
- ## # Server Error - try again.
- ## continue
-+ elif e.code == 404:
-+ ErrorExit("Error: RPC call to %s failed with status 404\n"
-+ "Check upload server is valid - %s" % (request_path, self.host))
- else:
- raise
- finally:
diff --git a/tests/data/failing/not-a-patch.log b/tests/data/failing/not-a-patch.log
deleted file mode 100644
index 49ed60c..0000000
--- a/tests/data/failing/not-a-patch.log
+++ /dev/null
@@ -1,9 +0,0 @@
-*get* '220 ftp.**********.com MadGoat FTP server V2.5-3 ready.\r\n'
-*resp* '220 ftp.**********.com MadGoat FTP server V2.5-3 ready.'
-*welcome* '220 ftp.**********.com MadGoat FTP server V2.5-3 ready.'
-*cmd* u'USER *******'
-*put* u'USER *******\r\n'
-*get* '331 Username "*******" Okay, need password.\r\n'
-*resp* '331 Username "*******" Okay, need password.'
-*cmd* u'PASS *******'
-*put* u'PASS *******\r\n'
diff --git a/tests/data/failing/upload.py b/tests/data/failing/upload.py
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/data/git-changed-2-files.diff b/tests/data/git-changed-2-files.diff
deleted file mode 100644
index 35fa18a..0000000
--- a/tests/data/git-changed-2-files.diff
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/jsonpickle/__init__.py b/jsonpickle/__init__.py
-index 22161dd..ea5ca6d 100644
---- a/jsonpickle/__init__.py
-+++ b/jsonpickle/__init__.py
-@@ -87,7 +87,12 @@ class JSONPluginMgr(object):
- self._decoders = {}
-
- ## Options to pass to specific encoders
-- self._encoder_options = {}
-+ json_opts = ((), {'sort_keys': True})
-+ self._encoder_options = {
-+ 'json': json_opts,
-+ 'simplejson': json_opts,
-+ 'django.util.simplejson': json_opts,
-+ }
-
- ## The exception class that is thrown when a decoding error occurs
- self._decoder_exceptions = {}
-diff --git a/tests/jsonpickle_test.py b/tests/jsonpickle_test.py
-index c61dec4..09ba339 100644
---- a/tests/jsonpickle_test.py
-+++ b/tests/jsonpickle_test.py
-@@ -427,6 +427,15 @@ class PicklingTestCase(unittest.TestCase):
- inflated = self.unpickler.restore(flattened)
- self.assertEqual(obj, inflated)
-
-+ def test_references(self):
-+ obj_a = Thing('foo')
-+ obj_b = Thing('bar')
-+ coll = [obj_a, obj_b, obj_b]
-+ flattened = self.pickler.flatten(coll)
-+ inflated = self.unpickler.restore(flattened)
-+ self.assertEqual(len(inflated), len(coll))
-+ for x in range(len(coll)):
-+ self.assertEqual(repr(coll[x]), repr(inflated[x]))
-
- class JSONPickleTestCase(unittest.TestCase):
- def setUp(self):
diff --git a/tests/data/git-changed-file.diff b/tests/data/git-changed-file.diff
deleted file mode 100644
index 35fa18a..0000000
--- a/tests/data/git-changed-file.diff
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/jsonpickle/__init__.py b/jsonpickle/__init__.py
-index 22161dd..ea5ca6d 100644
---- a/jsonpickle/__init__.py
-+++ b/jsonpickle/__init__.py
-@@ -87,7 +87,12 @@ class JSONPluginMgr(object):
- self._decoders = {}
-
- ## Options to pass to specific encoders
-- self._encoder_options = {}
-+ json_opts = ((), {'sort_keys': True})
-+ self._encoder_options = {
-+ 'json': json_opts,
-+ 'simplejson': json_opts,
-+ 'django.util.simplejson': json_opts,
-+ }
-
- ## The exception class that is thrown when a decoding error occurs
- self._decoder_exceptions = {}
-diff --git a/tests/jsonpickle_test.py b/tests/jsonpickle_test.py
-index c61dec4..09ba339 100644
---- a/tests/jsonpickle_test.py
-+++ b/tests/jsonpickle_test.py
-@@ -427,6 +427,15 @@ class PicklingTestCase(unittest.TestCase):
- inflated = self.unpickler.restore(flattened)
- self.assertEqual(obj, inflated)
-
-+ def test_references(self):
-+ obj_a = Thing('foo')
-+ obj_b = Thing('bar')
-+ coll = [obj_a, obj_b, obj_b]
-+ flattened = self.pickler.flatten(coll)
-+ inflated = self.unpickler.restore(flattened)
-+ self.assertEqual(len(inflated), len(coll))
-+ for x in range(len(coll)):
-+ self.assertEqual(repr(coll[x]), repr(inflated[x]))
-
- class JSONPickleTestCase(unittest.TestCase):
- def setUp(self):
diff --git a/tests/data/git-dash-in-filename.diff b/tests/data/git-dash-in-filename.diff
deleted file mode 100644
index 3ff528b..0000000
--- a/tests/data/git-dash-in-filename.diff
+++ /dev/null
@@ -1,21 +0,0 @@
-From fe0fecac607022e8a8017c5209b79e4fda342213 Mon Sep 17 00:00:00 2001
-From: "Dr. Matthias St. Pierre"
diff --git a/tests/data/svn-added-new-file-withcontent.diff b/tests/data/svn-added-new-file-withcontent.diff
deleted file mode 100644
index a1ac10f..0000000
--- a/tests/data/svn-added-new-file-withcontent.diff
+++ /dev/null
@@ -1,7 +0,0 @@
-Index: new-file.txt
-===================================================================
---- new-file.txt (revision 0)
-+++ new-file.txt (revision 0)
-@@ -0,0 +1 @@
-+with content
-\ No newline at end of file
diff --git a/tests/data/svn-changed-2-files.diff b/tests/data/svn-changed-2-files.diff
deleted file mode 100644
index 4f447e5..0000000
--- a/tests/data/svn-changed-2-files.diff
+++ /dev/null
@@ -1,86 +0,0 @@
-Index: trac/versioncontrol/svn_fs.py
-===================================================================
---- trac/versioncontrol/svn_fs.py (revision 8986)
-+++ trac/versioncontrol/svn_fs.py (working copy)
-@@ -289,7 +289,7 @@
- repos = fs_repos
- else:
- repos = CachedRepository(self.env.get_db_cnx, fs_repos, None,
-- self.log)
-+ self.log, self.env)
- repos.has_linear_changesets = True
- if authname:
- authz = SubversionAuthorizer(self.env, weakref.proxy(repos),
-Index: trac/versioncontrol/cache.py
-===================================================================
---- trac/versioncontrol/cache.py (revision 8986)
-+++ trac/versioncontrol/cache.py (working copy)
-@@ -18,7 +18,7 @@
- import os
- import posixpath
-
--from trac.core import TracError
-+from trac.core import *
- from trac.util.datefmt import utc, to_timestamp
- from trac.util.translation import _
- from trac.versioncontrol import Changeset, Node, Repository, Authorizer, \
-@@ -36,19 +36,42 @@
- CACHE_METADATA_KEYS = (CACHE_REPOSITORY_DIR, CACHE_YOUNGEST_REV)
-
-
-+class ICacheChangesetListener(Interface):
-+ """Cached changeset operations"""
-+
-+ def edit_changeset(cset):
-+ """Called when changeset is about to be cached.
-+ Returns altered data to cache or None if unchanged. cset usually
-+ contains cset.date, cset.author, cset.message and cset.rev
-+ """
-+
-+class CacheManager(Component):
-+ """Provide interface to plug-in into cache operations"""
-+
-+ observers = ExtensionPoint(ICacheChangesetListener)
-+
-+ def check_changeset(self, cset):
-+ for observer in self.observers:
-+ res = observer.edit_changeset(cset)
-+ if res != None:
-+ cset = res
-+ return cset
-+
-+
- class CachedRepository(Repository):
-
- has_linear_changesets = False
-
- scope = property(lambda self: self.repos.scope)
-
-- def __init__(self, getdb, repos, authz, log):
-+ def __init__(self, getdb, repos, authz, log, env):
- Repository.__init__(self, repos.name, authz, log)
- if callable(getdb):
- self.getdb = getdb
- else:
- self.getdb = lambda: getdb
- self.repos = repos
-+ self.cache_mgr = CacheManager(env)
-
- def close(self):
- self.repos.close()
-@@ -77,6 +100,7 @@
-
- def sync_changeset(self, rev):
- cset = self.repos.get_changeset(rev)
-+ cset = self.cache_mgr.check_changeset(cset)
- db = self.getdb()
- cursor = db.cursor()
- cursor.execute("UPDATE revision SET time=%s, author=%s, message=%s "
-@@ -182,6 +206,7 @@
- self.log.info("Trying to sync revision [%s]" %
- next_youngest)
- cset = self.repos.get_changeset(next_youngest)
-+ cset = self.cache_mgr.check_changeset(cset)
- try:
- cursor.execute("INSERT INTO revision "
- " (rev,time,author,message) "
diff --git a/tests/data/svn-modified-empty-file.diff b/tests/data/svn-modified-empty-file.diff
deleted file mode 100644
index 704a565..0000000
--- a/tests/data/svn-modified-empty-file.diff
+++ /dev/null
@@ -1,7 +0,0 @@
-Index: upload.py
-===================================================================
---- upload.py (revision 120)
-+++ upload.py (working copy)
-@@ -0,0 +1 @@
-+new info
-\ No newline at end of file
diff --git a/tests/recoverage.bat b/tests/recoverage.bat
deleted file mode 100644
index 2792a93..0000000
--- a/tests/recoverage.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-cd ..
-python -m coverage run tests/run_tests.py
-python -m coverage html -d tests/coverage
-python -m coverage report -m
diff --git a/tests/run_tests.py b/tests/run_tests.py
deleted file mode 100755
index 876aeae..0000000
--- a/tests/run_tests.py
+++ /dev/null
@@ -1,448 +0,0 @@
-#!/usr/bin/env python
-"""
-python-patch test suite
-
-There are two kind of tests:
- - file-based tests
- - directory-based tests
- - unit tests
-
-File-based test is patch file, initial file and resulting file
-for comparison.
-
-Directory-based test is a self-sufficient directory with:
-files to be patched, patch file itself and [result] dir. You can
-manually apply patch and compare outcome with [result] directory.
-This is what this test runner does.
-
-Unit tests test API and are all inside this runner.
-
-
-== Code Coverage ==
-
-To refresh code coverage stats, get 'coverage' tool from
-http://pypi.python.org/pypi/coverage/ and run this file with:
-
- coverage run run_tests.py
- coverage html -d coverage
-
-On Windows it may be more convenient instead of `coverage` call
-`python -m coverage.__main__`
-"""
-from __future__ import print_function
-
-import os
-import sys
-import re
-import shutil
-import unittest
-import copy
-from os import listdir
-from os.path import abspath, dirname, exists, join, isdir, isfile
-from tempfile import mkdtemp
-try:
- getcwdu = os.getcwdu
-except AttributeError:
- getcwdu = os.getcwd # python 3, where getcwd always returns a unicode object
-
-verbose = False
-if "-v" in sys.argv or "--verbose" in sys.argv:
- verbose = True
-
-
-# full path for directory with tests
-TESTS = dirname(abspath(__file__))
-TESTDATA = join(TESTS, 'data')
-def testfile(name):
- return join(TESTDATA, name)
-
-
-# import patch.py from parent directory
-save_path = sys.path
-sys.path.insert(0, dirname(TESTS))
-import patch
-sys.path = save_path
-
-
-# ----------------------------------------------------------------------------
-class TestPatchFiles(unittest.TestCase):
- """
- unittest hack - test* methods are generated by add_test_methods() function
- below dynamically using information about *.patch files from tests directory
-
- """
- def _assert_files_equal(self, file1, file2):
- f1 = f2 = None
- try:
- f1 = open(file1, "rb")
- f2 = open(file2, "rb")
- for line in f1:
- self.assertEqual(line, f2.readline())
-
- finally:
- if f2:
- f2.close()
- if f1:
- f1.close()
-
- def _assert_dirs_equal(self, dir1, dir2, ignore=[]):
- """
- compare dir2 with reference dir1, ignoring entries
- from supplied list
-
- """
- # recursive
- if type(ignore) == str:
- ignore = [ignore]
- e2list = [en for en in listdir(dir2) if en not in ignore]
- for e1 in listdir(dir1):
- if e1 in ignore:
- continue
- e1path = join(dir1, e1)
- e2path = join(dir2, e1)
- self.assertTrue(exists(e1path))
- self.assertTrue(exists(e2path), "%s does not exist" % e2path)
- self.assertTrue(isdir(e1path) == isdir(e2path))
- if not isdir(e1path):
- self._assert_files_equal(e1path, e2path)
- else:
- self._assert_dirs_equal(e1path, e2path, ignore=ignore)
- e2list.remove(e1)
- for e2 in e2list:
- self.fail("extra file or directory: %s" % e2)
-
-
- def _run_test(self, testname):
- """
- boilerplate for running *.patch file tests
- """
-
- # 1. create temp test directory
- # 2. copy files
- # 3. execute file-based patch
- # 4. compare results
- # 5. cleanup on success
-
- tmpdir = mkdtemp(prefix="%s."%testname)
-
- basepath = join(TESTS, testname)
- basetmp = join(tmpdir, testname)
-
- patch_file = basetmp + ".patch"
-
- file_based = isfile(basepath + ".from")
- from_tgt = basetmp + ".from"
-
- if file_based:
- shutil.copy(basepath + ".from", tmpdir)
- shutil.copy(basepath + ".patch", tmpdir)
- else:
- # directory-based
- for e in listdir(basepath):
- epath = join(basepath, e)
- if not isdir(epath):
- shutil.copy(epath, join(tmpdir, e))
- else:
- shutil.copytree(epath, join(tmpdir, e))
-
-
- # 3.
- # test utility as a whole
- patch_tool = join(dirname(TESTS), "patch.py")
- save_cwd = getcwdu()
- os.chdir(tmpdir)
- if verbose:
- cmd = '%s %s "%s"' % (sys.executable, patch_tool, patch_file)
- print("\n"+cmd)
- else:
- cmd = '%s %s -q "%s"' % (sys.executable, patch_tool, patch_file)
- ret = os.system(cmd)
- assert ret == 0, "Error %d running test %s" % (ret, testname)
- os.chdir(save_cwd)
-
-
- # 4.
- # compare results
- if file_based:
- self._assert_files_equal(basepath + ".to", from_tgt)
- else:
- # recursive comparison
- self._assert_dirs_equal(join(basepath, "[result]"),
- tmpdir,
- ignore=["%s.patch" % testname, ".svn", "[result]"])
-
-
- shutil.rmtree(tmpdir)
- return 0
-
-
-def add_test_methods(cls):
- """
- hack to generate test* methods in target class - one
- for each *.patch file in tests directory
- """
-
- # list testcases - every test starts with number
- # and add them as test* methods
- testptn = re.compile(r"^(?P