summaryrefslogtreecommitdiff
path: root/fastimport/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@jelmer.uk>2019-12-01 16:06:43 +0000
committerJelmer Vernooij <jelmer@jelmer.uk>2019-12-01 16:06:43 +0000
commitcf8a7f49db9df39af8f0b8ca17b2546a447ffabd (patch)
tree05c24c0cda59cf1466e824262e7c637db7760236 /fastimport/tests
parentbca03bde748f9d106d7f762b509ab3888ddbce80 (diff)
downloadpython-fastimport-git-cf8a7f49db9df39af8f0b8ca17b2546a447ffabd.tar.gz
Fix PEP8 formatting.
Diffstat (limited to 'fastimport/tests')
-rw-r--r--fastimport/tests/test_commands.py74
-rw-r--r--fastimport/tests/test_dates.py1
-rw-r--r--fastimport/tests/test_errors.py27
-rw-r--r--fastimport/tests/test_filter_processor.py179
-rw-r--r--fastimport/tests/test_helpers.py3
-rw-r--r--fastimport/tests/test_info_processor.py1
-rw-r--r--fastimport/tests/test_parser.py23
7 files changed, 182 insertions, 126 deletions
diff --git a/fastimport/tests/test_commands.py b/fastimport/tests/test_commands.py
index ccae34a..8075661 100644
--- a/fastimport/tests/test_commands.py
+++ b/fastimport/tests/test_commands.py
@@ -50,7 +50,8 @@ class TestCommitDisplay(TestCase):
def test_commit(self):
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b"refs/heads/master", b"bbb", None, committer,
+ c = commands.CommitCommand(
+ b"refs/heads/master", b"bbb", None, committer,
b"release v1.0", b":aaa", None, None)
self.assertEqual(
b"commit refs/heads/master\n"
@@ -75,7 +76,8 @@ class TestCommitDisplay(TestCase):
)
committer = (name, b'test@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b'refs/heads/master', b'bbb', None, committer,
+ c = commands.CommitCommand(
+ b'refs/heads/master', b'bbb', None, committer,
b'release v1.0', b':aaa', None, None)
self.assertEqual(commit_utf8, repr_bytes(c))
@@ -83,8 +85,9 @@ class TestCommitDisplay(TestCase):
def test_commit_no_mark(self):
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b'refs/heads/master', None, None, committer,
- b'release v1.0', b':aaa', None, None)
+ c = commands.CommitCommand(
+ b'refs/heads/master', None, None, committer,
+ b'release v1.0', b':aaa', None, None)
self.assertEqual(
b"commit refs/heads/master\n"
b"committer Joe Wong <joe@example.com> 1234567890 -0600\n"
@@ -96,7 +99,8 @@ class TestCommitDisplay(TestCase):
def test_commit_no_from(self):
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b"refs/heads/master", b"bbb", None, committer,
+ c = commands.CommitCommand(
+ b"refs/heads/master", b"bbb", None, committer,
b"release v1.0", None, None, None)
self.assertEqual(
b"commit refs/heads/master\n"
@@ -110,7 +114,8 @@ class TestCommitDisplay(TestCase):
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
author = (b'Sue Wong', b'sue@example.com', 1234565432, -6 * 3600)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b'refs/heads/master', b'bbb', author,
+ c = commands.CommitCommand(
+ b'refs/heads/master', b'bbb', author,
committer, b'release v1.0', b':aaa', None, None)
self.assertEqual(
b"commit refs/heads/master\n"
@@ -125,7 +130,8 @@ class TestCommitDisplay(TestCase):
def test_commit_with_merges(self):
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b"refs/heads/master", b"ddd", None, committer,
+ c = commands.CommitCommand(
+ b"refs/heads/master", b"ddd", None, committer,
b'release v1.0', b":aaa", [b':bbb', b':ccc'], None)
self.assertEqual(
b"commit refs/heads/master\n"
@@ -141,12 +147,13 @@ class TestCommitDisplay(TestCase):
def test_commit_with_filecommands(self):
file_cmds = iter([
commands.FileDeleteCommand(b'readme.txt'),
- commands.FileModifyCommand(b'NEWS', 0o100644, None,
- b'blah blah blah'),
+ commands.FileModifyCommand(
+ b'NEWS', 0o100644, None, b'blah blah blah'),
])
# user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.CommitCommand(b'refs/heads/master', b'bbb', None, committer,
+ c = commands.CommitCommand(
+ b'refs/heads/master', b'bbb', None, committer,
b'release v1.0', b':aaa', None, file_cmds)
self.assertEqual(
b"commit refs/heads/master\n"
@@ -169,7 +176,8 @@ class TestCommitDisplay(TestCase):
(b'Al Smith', b'al@example.com', 1234565432, -6 * 3600),
(b'Bill Jones', b'bill@example.com', 1234565432, -6 * 3600),
]
- c = commands.CommitCommand(b'refs/heads/master', b'bbb', author,
+ c = commands.CommitCommand(
+ b'refs/heads/master', b'bbb', author,
committer, b'release v1.0', b':aaa', None, None,
more_authors=more_authors)
self.assertEqual(
@@ -191,7 +199,8 @@ class TestCommitDisplay(TestCase):
u'greeting': u'hello',
u'planet': u'world',
}
- c = commands.CommitCommand(b'refs/heads/master', b'bbb', None,
+ c = commands.CommitCommand(
+ b'refs/heads/master', b'bbb', None,
committer, b'release v1.0', b':aaa', None, None,
properties=properties)
self.assertEqual(
@@ -212,7 +221,8 @@ class TestCommitDisplay(TestCase):
u'greeting': u'hello',
u'planet': u'world',
}
- c = commands.CommitCommand(b'refs/heads/master', 123, None,
+ c = commands.CommitCommand(
+ b'refs/heads/master', 123, None,
committer, b'release v1.0', b':aaa', None, None,
properties=properties)
self.assertEqual(
@@ -226,13 +236,15 @@ class TestCommitDisplay(TestCase):
b"property planet 5 world",
repr_bytes(c))
+
class TestCommitCopy(TestCase):
def setUp(self):
super(TestCommitCopy, self).setUp()
file_cmds = iter([
commands.FileDeleteCommand(b'readme.txt'),
- commands.FileModifyCommand(b'NEWS', 0o100644, None, b'blah blah blah'),
+ commands.FileModifyCommand(
+ b'NEWS', 0o100644, None, b'blah blah blah'),
])
committer = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
@@ -256,6 +268,7 @@ class TestCommitCopy(TestCase):
def test_invalid_attribute(self):
self.assertRaises(TypeError, self.c.copy, invalid=True)
+
class TestFeatureDisplay(TestCase):
def test_feature(self):
@@ -290,7 +303,8 @@ class TestTagDisplay(TestCase):
def test_tag(self):
# tagger tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
tagger = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.TagCommand(b'refs/tags/v1.0', b':xxx', tagger, b'create v1.0')
+ c = commands.TagCommand(
+ b'refs/tags/v1.0', b':xxx', tagger, b'create v1.0')
self.assertEqual(
b"tag refs/tags/v1.0\n"
b"from :xxx\n"
@@ -301,7 +315,8 @@ class TestTagDisplay(TestCase):
def test_tag_no_from(self):
tagger = (b'Joe Wong', b'joe@example.com', 1234567890, -6 * 3600)
- c = commands.TagCommand(b'refs/tags/v1.0', None, tagger, b'create v1.0')
+ c = commands.TagCommand(
+ b'refs/tags/v1.0', None, tagger, b'create v1.0')
self.assertEqual(
b"tag refs/tags/v1.0\n"
b"tagger Joe Wong <joe@example.com> 1234567890 -0600\n"
@@ -321,18 +336,21 @@ class TestFileModifyDisplay(TestCase):
self.assertEqual(b'M 755 :23 foo/bar', repr_bytes(c))
def test_filemodify_file_internal(self):
- c = commands.FileModifyCommand(b'foo/bar', 0o100644, None,
- b'hello world')
- self.assertEqual(b'M 644 inline foo/bar\ndata 11\nhello world', repr_bytes(c))
+ c = commands.FileModifyCommand(
+ b'foo/bar', 0o100644, None, b'hello world')
+ self.assertEqual(
+ b'M 644 inline foo/bar\ndata 11\nhello world', repr_bytes(c))
def test_filemodify_symlink(self):
c = commands.FileModifyCommand(b'foo/bar', 0o120000, None, b'baz')
- self.assertEqual(b'M 120000 inline foo/bar\ndata 3\nbaz', repr_bytes(c))
+ self.assertEqual(
+ b'M 120000 inline foo/bar\ndata 3\nbaz', repr_bytes(c))
def test_filemodify_treeref(self):
- c = commands.FileModifyCommand(b'tree-info', 0o160000,
- b'revision-id-info', None)
- self.assertEqual(b'M 160000 revision-id-info tree-info', repr_bytes(c))
+ c = commands.FileModifyCommand(
+ b'tree-info', 0o160000, b'revision-id-info', None)
+ self.assertEqual(
+ b'M 160000 revision-id-info tree-info', repr_bytes(c))
class TestFileDeleteDisplay(TestCase):
@@ -372,11 +390,13 @@ class TestFileDeleteAllDisplay(TestCase):
c = commands.FileDeleteAllCommand()
self.assertEqual(b'deleteall', repr_bytes(c))
+
class TestNotesDisplay(TestCase):
def test_noteonly(self):
c = commands.NoteModifyCommand(b'foo', b'A basic note')
- self.assertEqual(b'N inline :foo\ndata 12\nA basic note', repr_bytes(c))
+ self.assertEqual(
+ b'N inline :foo\ndata 12\nA basic note', repr_bytes(c))
def test_notecommit(self):
committer = (b'Ed Mund', b'ed@example.org', 1234565432, 0)
@@ -449,9 +469,11 @@ Test test
class TestPathChecking(TestCase):
def test_filemodify_path_checking(self):
- self.assertRaises(ValueError, commands.FileModifyCommand, b'',
+ self.assertRaises(
+ ValueError, commands.FileModifyCommand, b'',
0o100644, None, b'text')
- self.assertRaises(ValueError, commands.FileModifyCommand, None,
+ self.assertRaises(
+ ValueError, commands.FileModifyCommand, None,
0o100644, None, b'text')
def test_filedelete_path_checking(self):
diff --git a/fastimport/tests/test_dates.py b/fastimport/tests/test_dates.py
index f1ccd67..cc2617f 100644
--- a/fastimport/tests/test_dates.py
+++ b/fastimport/tests/test_dates.py
@@ -21,6 +21,7 @@ from fastimport import (
dates,
)
+
class ParseTzTests(TestCase):
def test_parse_tz_utc(self):
diff --git a/fastimport/tests/test_errors.py b/fastimport/tests/test_errors.py
index 4fc7dcd..895f783 100644
--- a/fastimport/tests/test_errors.py
+++ b/fastimport/tests/test_errors.py
@@ -25,27 +25,28 @@ class TestErrors(TestCase):
def test_MissingBytes(self):
e = errors.MissingBytes(99, 10, 8)
- self.assertEqual("line 99: Unexpected EOF - expected 10 bytes, found 8",
+ self.assertEqual(
+ "line 99: Unexpected EOF - expected 10 bytes, found 8",
str(e))
def test_MissingTerminator(self):
e = errors.MissingTerminator(99, '---')
- self.assertEqual("line 99: Unexpected EOF - expected '---' terminator",
+ self.assertEqual(
+ "line 99: Unexpected EOF - expected '---' terminator",
str(e))
def test_InvalidCommand(self):
e = errors.InvalidCommand(99, 'foo')
- self.assertEqual("line 99: Invalid command 'foo'",
- str(e))
+ self.assertEqual("line 99: Invalid command 'foo'", str(e))
def test_MissingSection(self):
e = errors.MissingSection(99, 'foo', 'bar')
- self.assertEqual("line 99: Command foo is missing section bar",
- str(e))
+ self.assertEqual("line 99: Command foo is missing section bar", str(e))
def test_BadFormat(self):
e = errors.BadFormat(99, 'foo', 'bar', 'xyz')
- self.assertEqual("line 99: Bad format for section bar in "
+ self.assertEqual(
+ "line 99: Bad format for section bar in "
"command foo: found 'xyz'",
str(e))
@@ -53,14 +54,15 @@ class TestErrors(TestCase):
e = errors.InvalidTimezone(99, 'aa:bb')
self.assertEqual('aa:bb', e.timezone)
self.assertEqual('', e.reason)
- self.assertEqual("line 99: Timezone 'aa:bb' could not be converted.",
+ self.assertEqual(
+ "line 99: Timezone 'aa:bb' could not be converted.",
str(e))
e = errors.InvalidTimezone(99, 'aa:bb', 'Non-numeric hours')
self.assertEqual('aa:bb', e.timezone)
self.assertEqual(' Non-numeric hours', e.reason)
- self.assertEqual("line 99: Timezone 'aa:bb' could not be converted."
- " Non-numeric hours",
- str(e))
+ self.assertEqual(
+ "line 99: Timezone 'aa:bb' could not be converted."
+ " Non-numeric hours", str(e))
def test_UnknownDateFormat(self):
e = errors.UnknownDateFormat('aaa')
@@ -72,5 +74,6 @@ class TestErrors(TestCase):
def test_UnknownFeature(self):
e = errors.UnknownFeature('aaa')
- self.assertEqual("Unknown feature 'aaa' - try a later importer or "
+ self.assertEqual(
+ "Unknown feature 'aaa' - try a later importer or "
"an earlier data format", str(e))
diff --git a/fastimport/tests/test_filter_processor.py b/fastimport/tests/test_filter_processor.py
index 809bdc8..7659db1 100644
--- a/fastimport/tests/test_filter_processor.py
+++ b/fastimport/tests/test_filter_processor.py
@@ -28,8 +28,8 @@ from fastimport.processors import (
# A sample input stream containing all (top level) import commands
-_SAMPLE_ALL = \
-b"""blob
+_SAMPLE_ALL = b"""\
+blob
mark :1
data 4
foo
@@ -56,8 +56,8 @@ release v0.1
# NEWS
# doc/README.txt
# doc/index.txt
-_SAMPLE_WITH_DIR = \
-b"""blob
+_SAMPLE_WITH_DIR = b"""\
+blob
mark :1
data 9
Welcome!
@@ -101,6 +101,7 @@ M 644 :3 doc/README.txt
M 644 :4 doc/index.txt
"""
+
class TestCaseWithFiltering(TestCase):
def assertFiltering(self, input_stream, params, expected):
@@ -114,6 +115,7 @@ class TestCaseWithFiltering(TestCase):
out = outf.getvalue()
self.assertEqual(expected, out)
+
class TestNoFiltering(TestCaseWithFiltering):
def test_params_not_given(self):
@@ -131,8 +133,8 @@ class TestIncludePaths(TestCaseWithFiltering):
# * only referenced blobs are retained
# * from clause is dropped from the first command
params = {b'include_paths': [b'NEWS']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :2
data 17
Life
@@ -152,8 +154,8 @@ M 644 :2 NEWS
# * new root: path is now index.txt, not doc/index.txt
# * other files changed in matching commits are excluded
params = {b'include_paths': [b'doc/index.txt']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :4
data 11
== Docs ==
@@ -170,8 +172,8 @@ M 644 :4 index.txt
# Additional things to note:
# * from updated to reference parents in the output
params = {b'include_paths': [b'doc/README.txt']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -198,8 +200,8 @@ M 644 :3 README.txt
def test_subdir(self):
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -232,8 +234,8 @@ M 644 :4 index.txt
def test_multiple_files_in_subdir(self):
# The new root should be the subdrectory
params = {b'include_paths': [b'doc/README.txt', b'doc/index.txt']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -268,8 +270,8 @@ class TestExcludePaths(TestCaseWithFiltering):
def test_file_in_root(self):
params = {b'exclude_paths': [b'NEWS']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -301,8 +303,8 @@ M 644 :4 doc/index.txt
def test_file_in_subdir(self):
params = {b'exclude_paths': [b'doc/README.txt']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :2
data 17
Life
@@ -331,8 +333,8 @@ M 644 :4 doc/index.txt
def test_subdir(self):
params = {b'exclude_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :2
data 17
Life
@@ -349,8 +351,8 @@ M 644 :2 NEWS
def test_multple_files(self):
params = {b'exclude_paths': [b'doc/index.txt', b'NEWS']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -379,9 +381,11 @@ M 644 :3 doc/README.txt
class TestIncludeAndExcludePaths(TestCaseWithFiltering):
def test_included_dir_and_excluded_file(self):
- params = {b'include_paths': [b'doc/'], b'exclude_paths': [b'doc/index.txt']}
- self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-b"""blob
+ params = {
+ b'include_paths': [b'doc/'],
+ b'exclude_paths': [b'doc/index.txt']}
+ self.assertFiltering(_SAMPLE_WITH_DIR, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -414,8 +418,8 @@ M 644 :3 README.txt
# doc/index.txt
#
# It then renames doc/README.txt => doc/README
-_SAMPLE_WITH_RENAME_INSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_RENAME_INSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -431,8 +435,8 @@ R doc/README.txt doc/README
# doc/index.txt
#
# It then renames doc/README.txt => README
-_SAMPLE_WITH_RENAME_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_RENAME_TO_OUTSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -448,8 +452,8 @@ R doc/README.txt README
# doc/index.txt
#
# It then renames NEWS => doc/NEWS
-_SAMPLE_WITH_RENAME_TO_INSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_RENAME_TO_INSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -458,13 +462,14 @@ from :102
R NEWS doc/NEWS
"""
+
class TestIncludePathsWithRenames(TestCaseWithFiltering):
def test_rename_all_inside(self):
# These rename commands ought to be kept but adjusted for the new root
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_RENAME_INSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_RENAME_INSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -504,8 +509,8 @@ R README.txt README
def test_rename_to_outside(self):
# These rename commands become deletes
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_RENAME_TO_OUTSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_RENAME_TO_OUTSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -545,8 +550,8 @@ D README.txt
def test_rename_to_inside(self):
# This ought to create a new file but doesn't yet
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_RENAME_TO_INSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_RENAME_TO_INSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -584,8 +589,8 @@ M 644 :4 index.txt
# doc/index.txt
#
# It then copies doc/README.txt => doc/README
-_SAMPLE_WITH_COPY_INSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_COPY_INSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -601,8 +606,8 @@ C doc/README.txt doc/README
# doc/index.txt
#
# It then copies doc/README.txt => README
-_SAMPLE_WITH_COPY_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_COPY_TO_OUTSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -618,8 +623,8 @@ C doc/README.txt README
# doc/index.txt
#
# It then copies NEWS => doc/NEWS
-_SAMPLE_WITH_COPY_TO_INSIDE = _SAMPLE_WITH_DIR + \
-b"""commit refs/heads/master
+_SAMPLE_WITH_COPY_TO_INSIDE = _SAMPLE_WITH_DIR + b"""\
+commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
@@ -634,8 +639,8 @@ class TestIncludePathsWithCopies(TestCaseWithFiltering):
def test_copy_all_inside(self):
# These copy commands ought to be kept but adjusted for the new root
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_COPY_INSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_COPY_INSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -675,8 +680,8 @@ C README.txt README
def test_copy_to_outside(self):
# This can be ignored
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_COPY_TO_OUTSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_COPY_TO_OUTSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -709,8 +714,8 @@ M 644 :4 index.txt
def test_copy_to_inside(self):
# This ought to create a new file but doesn't yet
params = {b'include_paths': [b'doc/']}
- self.assertFiltering(_SAMPLE_WITH_COPY_TO_INSIDE, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_COPY_TO_INSIDE, params, b"""\
+blob
mark :1
data 9
Welcome!
@@ -746,8 +751,8 @@ M 644 :4 index.txt
# NEWS
# doc/README.txt
# doc/index.txt
-_SAMPLE_WITH_DELETEALL = \
-b"""blob
+_SAMPLE_WITH_DELETEALL = b"""\
+blob
mark :1
data 9
Welcome!
@@ -784,8 +789,8 @@ class TestIncludePathsWithDeleteAll(TestCaseWithFiltering):
def test_deleteall(self):
params = {b'include_paths': [b'doc/index.txt']}
- self.assertFiltering(_SAMPLE_WITH_DELETEALL, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_DELETEALL, params, b"""\
+blob
mark :4
data 11
== Docs ==
@@ -801,8 +806,8 @@ M 644 :4 index.txt
""")
-_SAMPLE_WITH_TAGS = _SAMPLE_WITH_DIR + \
-b"""tag v0.1
+_SAMPLE_WITH_TAGS = _SAMPLE_WITH_DIR + b"""\
+tag v0.1
from :100
tagger d <b@c> 1234798653 +0000
data 12
@@ -814,6 +819,7 @@ data 12
release v0.2
"""
+
class TestIncludePathsWithTags(TestCaseWithFiltering):
def test_tag_retention(self):
@@ -821,8 +827,8 @@ class TestIncludePathsWithTags(TestCaseWithFiltering):
# keep the tag but adjust 'from' accordingly.
# Otherwise, delete the tag command.
params = {b'include_paths': [b'NEWS']}
- self.assertFiltering(_SAMPLE_WITH_TAGS, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_TAGS, params, b"""\
+blob
mark :2
data 17
Life
@@ -843,12 +849,13 @@ release v0.2
""")
-_SAMPLE_WITH_RESETS = _SAMPLE_WITH_DIR + \
-b"""reset refs/heads/foo
+_SAMPLE_WITH_RESETS = _SAMPLE_WITH_DIR + b"""\
+reset refs/heads/foo
reset refs/heads/bar
from :102
"""
+
class TestIncludePathsWithResets(TestCaseWithFiltering):
def test_reset_retention(self):
@@ -856,8 +863,8 @@ class TestIncludePathsWithResets(TestCaseWithFiltering):
# If a reset references a commit with a parent we kept,
# keep the reset but adjust 'from' accordingly.
params = {b'include_paths': [b'NEWS']}
- self.assertFiltering(_SAMPLE_WITH_RESETS, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_WITH_RESETS, params, b"""\
+blob
mark :2
data 17
Life
@@ -877,8 +884,8 @@ from :101
# A sample input stream containing empty commit
-_SAMPLE_EMPTY_COMMIT = \
-b"""blob
+_SAMPLE_EMPTY_COMMIT = b"""\
+blob
mark :1
data 4
foo
@@ -896,8 +903,8 @@ empty commit
"""
# A sample input stream containing unresolved from and merge references
-_SAMPLE_FROM_MERGE_COMMIT = \
-b"""blob
+_SAMPLE_FROM_MERGE_COMMIT = b"""\
+blob
mark :1
data 4
foo
@@ -933,12 +940,13 @@ merge :1001
M 644 :99 data/DATA2
"""
+
class TestSquashEmptyCommitsFlag(TestCaseWithFiltering):
def test_squash_empty_commit(self):
params = {b'include_paths': None, b'exclude_paths': None}
- self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, b"""\
+blob
mark :1
data 4
foo
@@ -951,13 +959,18 @@ M 644 :1 COPYING
""")
def test_keep_empty_commit(self):
- params = {b'include_paths': None, b'exclude_paths': None, b'squash_empty_commits': False}
- self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, _SAMPLE_EMPTY_COMMIT)
+ params = {
+ b'include_paths': None,
+ b'exclude_paths': None,
+ b'squash_empty_commits': False,
+ }
+ self.assertFiltering(
+ _SAMPLE_EMPTY_COMMIT, params, _SAMPLE_EMPTY_COMMIT)
def test_squash_unresolved_references(self):
params = {b'include_paths': None, b'exclude_paths': None}
- self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, b"""\
+blob
mark :1
data 4
foo
@@ -994,15 +1007,20 @@ M 644 :99 data/DATA2
""")
def test_keep_unresolved_from_and_merge(self):
- params = {b'include_paths': None, b'exclude_paths': None, b'squash_empty_commits': False}
- self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, _SAMPLE_FROM_MERGE_COMMIT)
+ params = {
+ b'include_paths': None,
+ b'exclude_paths': None,
+ b'squash_empty_commits': False,
+ }
+ self.assertFiltering(
+ _SAMPLE_FROM_MERGE_COMMIT, params, _SAMPLE_FROM_MERGE_COMMIT)
def test_with_excludes(self):
params = {b'include_paths': None,
b'exclude_paths': [b'data/DATA'],
b'squash_empty_commits': False}
- self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, b"""\
+blob
mark :1
data 4
foo
@@ -1037,8 +1055,8 @@ M 644 :99 data/DATA2
params = {b'include_paths': [b'COPYING', b'data/DATA2'],
b'exclude_paths': None,
b'squash_empty_commits': False}
- self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-b"""blob
+ self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, b"""\
+blob
mark :1
data 4
foo
@@ -1067,15 +1085,14 @@ from :3
merge :4
merge :1001
M 644 :99 data/DATA2
-"""
-)
+""")
def test_with_directory_includes(self):
params = {b'include_paths': [b'data/'],
b'exclude_paths': None,
b'squash_empty_commits': False}
- self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-b"""commit refs/heads/master
+ self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, b"""\
+commit refs/heads/master
mark :3
committer Joe <joe@example.com> 1234567890 +1000
data 6
diff --git a/fastimport/tests/test_helpers.py b/fastimport/tests/test_helpers.py
index 3198cea..f695a60 100644
--- a/fastimport/tests/test_helpers.py
+++ b/fastimport/tests/test_helpers.py
@@ -51,5 +51,6 @@ class TestCommonDirectory(unittest.TestCase):
self.assertEqual(c, b'foo/bar/')
def test_lots_of_paths(self):
- c = helpers.common_directory([b'foo/bar/x', b'foo/bar/y', b'foo/bar/z'])
+ c = helpers.common_directory(
+ [b'foo/bar/x', b'foo/bar/y', b'foo/bar/z'])
self.assertEqual(c, b'foo/bar/')
diff --git a/fastimport/tests/test_info_processor.py b/fastimport/tests/test_info_processor.py
index 6904b50..f86fd1f 100644
--- a/fastimport/tests/test_info_processor.py
+++ b/fastimport/tests/test_info_processor.py
@@ -39,6 +39,7 @@ initial
"""
+
class TestFastImportInfo(TestCase):
def test_simple(self):
diff --git a/fastimport/tests/test_parser.py b/fastimport/tests/test_parser.py
index 5084dc9..cfbe096 100644
--- a/fastimport/tests/test_parser.py
+++ b/fastimport/tests/test_parser.py
@@ -143,10 +143,14 @@ multi-author test
"""
_timefunc = time.time
+
+
class TestImportParser(unittest.TestCase):
+
def setUp(self):
self.fake_time = 42.0123
time.time = lambda: self.fake_time
+
def tearDown(self):
time.time = _timefunc
del self.fake_time
@@ -181,9 +185,12 @@ class TestImportParser(unittest.TestCase):
self.assertEqual(b'commit', cmd4.name)
self.assertEqual(b'2', cmd4.mark)
self.assertEqual(b':2', cmd4.id)
- self.assertEqual(b'initial import', cmd4.message)
+ self.assertEqual(
+ b'initial import', cmd4.message)
- self.assertEqual((b'bugs bunny', b'bugs@bunny.org', self.fake_time, 0), cmd4.committer)
+ self.assertEqual(
+ (b'bugs bunny', b'bugs@bunny.org', self.fake_time, 0),
+ cmd4.committer)
# namedtuple attributes
self.assertEqual(b'bugs bunny', cmd4.committer.name)
self.assertEqual(b'bugs@bunny.org', cmd4.committer.email)
@@ -205,7 +212,8 @@ class TestImportParser(unittest.TestCase):
self.assertEqual(None, cmd5.mark)
self.assertEqual(b'@19', cmd5.id)
self.assertEqual(b'second commit', cmd5.message)
- self.assertEqual((b'', b'bugs@bunny.org', self.fake_time, 0), cmd5.committer)
+ self.assertEqual(
+ (b'', b'bugs@bunny.org', self.fake_time, 0), cmd5.committer)
self.assertEqual(None, cmd5.author)
self.assertEqual(19, cmd5.lineno)
self.assertEqual(b'refs/heads/master', cmd5.ref)
@@ -300,7 +308,8 @@ class TestStringParsing(unittest.TestCase):
def test_unquote(self):
s = br'hello \"sweet\" wo\\r\tld'
- self.assertEqual(br'hello "sweet" wo\r' + b'\tld',
+ self.assertEqual(
+ br'hello "sweet" wo\r' + b'\tld',
parser._unquote_c_string(s))
@@ -312,7 +321,8 @@ class TestPathPairParsing(unittest.TestCase):
def test_path_pair_spaces_in_first(self):
p = parser.ImportParser("")
- self.assertEqual([b'foo bar', b'baz'],
+ self.assertEqual(
+ [b'foo bar', b'baz'],
p._path_pair(b'"foo bar" baz'))
@@ -328,7 +338,8 @@ class TestTagParsing(unittest.TestCase):
cmds = list(p.iter_commands())
self.assertEqual(1, len(cmds))
self.assertTrue(isinstance(cmds[0], commands.TagCommand))
- self.assertEqual(cmds[0].tagger,
+ self.assertEqual(
+ cmds[0].tagger,
(b'Joe Wong', b'joe@example.com', 1234567890.0, -21600))
def test_tagger_no_email_strict(self):