patman: Assume we always have pygit2 for tests

Given that we have tests that require pygit2 and it can be installed
like any other python module, fail much more loudly if it is missing.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tom Rini 2021-02-26 07:52:31 -05:00 committed by Simon Glass
parent 5f0d23cf3c
commit 2959a8e3a5

View File

@ -25,13 +25,8 @@ from patman import terminal
from patman import tools from patman import tools
from patman.test_util import capture_sys_output from patman.test_util import capture_sys_output
try: import pygit2
import pygit2 from patman import status
HAVE_PYGIT2 = True
from patman import status
except ModuleNotFoundError:
HAVE_PYGIT2 = False
class TestFunctional(unittest.TestCase): class TestFunctional(unittest.TestCase):
"""Functional tests for checking that patman behaves correctly""" """Functional tests for checking that patman behaves correctly"""
@ -458,7 +453,6 @@ complicated as possible''')
repo.branches.local.create('base', base_target) repo.branches.local.create('base', base_target)
return repo return repo
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testBranch(self): def testBranch(self):
"""Test creating patches from a branch""" """Test creating patches from a branch"""
repo = self.make_git_tree() repo = self.make_git_tree()
@ -604,7 +598,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
["Found possible blank line(s) at end of file 'lib/fdtdec.c'"], ["Found possible blank line(s) at end of file 'lib/fdtdec.c'"],
pstrm.commit.warn) pstrm.commit.warn)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testNoUpstream(self): def testNoUpstream(self):
"""Test CountCommitsToBranch when there is no upstream""" """Test CountCommitsToBranch when there is no upstream"""
repo = self.make_git_tree() repo = self.make_git_tree()
@ -642,7 +635,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
{'id': '1', 'name': 'Some patch'}]} {'id': '1', 'name': 'Some patch'}]}
raise ValueError('Fake Patchwork does not understand: %s' % subpath) raise ValueError('Fake Patchwork does not understand: %s' % subpath)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testStatusMismatch(self): def testStatusMismatch(self):
"""Test Patchwork patches not matching the series""" """Test Patchwork patches not matching the series"""
series = Series() series = Series()
@ -652,7 +644,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
self.assertIn('Warning: Patchwork reports 1 patches, series has 0', self.assertIn('Warning: Patchwork reports 1 patches, series has 0',
err.getvalue()) err.getvalue())
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testStatusReadPatch(self): def testStatusReadPatch(self):
"""Test handling a single patch in Patchwork""" """Test handling a single patch in Patchwork"""
series = Series() series = Series()
@ -665,7 +656,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
self.assertEqual('1', patch.id) self.assertEqual('1', patch.id)
self.assertEqual('Some patch', patch.raw_subject) self.assertEqual('Some patch', patch.raw_subject)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testParseSubject(self): def testParseSubject(self):
"""Test parsing of the patch subject""" """Test parsing of the patch subject"""
patch = status.Patch('1') patch = status.Patch('1')
@ -728,7 +718,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
self.assertEqual('RESEND', patch.prefix) self.assertEqual('RESEND', patch.prefix)
self.assertEqual(None, patch.version) self.assertEqual(None, patch.version)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testCompareSeries(self): def testCompareSeries(self):
"""Test operation of compare_with_series()""" """Test operation of compare_with_series()"""
commit1 = Commit('abcd') commit1 = Commit('abcd')
@ -831,7 +820,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
return patch.comments return patch.comments
raise ValueError('Fake Patchwork does not understand: %s' % subpath) raise ValueError('Fake Patchwork does not understand: %s' % subpath)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testFindNewResponses(self): def testFindNewResponses(self):
"""Test operation of find_new_responses()""" """Test operation of find_new_responses()"""
commit1 = Commit('abcd') commit1 = Commit('abcd')
@ -970,7 +958,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
return patch.comments return patch.comments
raise ValueError('Fake Patchwork does not understand: %s' % subpath) raise ValueError('Fake Patchwork does not understand: %s' % subpath)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testCreateBranch(self): def testCreateBranch(self):
"""Test operation of create_branch()""" """Test operation of create_branch()"""
repo = self.make_git_tree() repo = self.make_git_tree()
@ -1058,7 +1045,6 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
self.assertEqual('Reviewed-by: %s' % self.mary, next(lines)) self.assertEqual('Reviewed-by: %s' % self.mary, next(lines))
self.assertEqual('Tested-by: %s' % self.leb, next(lines)) self.assertEqual('Tested-by: %s' % self.leb, next(lines))
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testParseSnippets(self): def testParseSnippets(self):
"""Test parsing of review snippets""" """Test parsing of review snippets"""
text = '''Hi Fred, text = '''Hi Fred,
@ -1142,7 +1128,6 @@ line8
'line2', 'line3', 'line4', 'line5', 'line6', 'line7', 'line8']], 'line2', 'line3', 'line4', 'line5', 'line6', 'line7', 'line8']],
pstrm.snippets) pstrm.snippets)
@unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
def testReviewSnippets(self): def testReviewSnippets(self):
"""Test showing of review snippets""" """Test showing of review snippets"""
def _to_submitter(who): def _to_submitter(who):