def testRaisesWhenBadVersionNumber(self): self.subprocess_mock.return_value = 'git version x' with self.assertRaisesRegex( git.InvalidGitException, ('The git version string must contain a version number')): git.CheckGitVersion(self.min_version)
def testRaisesWhenNotFound(self): self.subprocess_mock.side_effect = OSError(errno.ENOENT, 'not found') with self.assertRaisesRegex( git.NoGitException, ('Cannot find git. Please install git and try again.')): git.CheckGitVersion(self.min_version)
def testRaisesWhenBadOutput(self): self.subprocess_mock.return_value = 'sit versi' with self.assertRaisesRegex( git.InvalidGitException, ('The git version string must start with git version')): git.CheckGitVersion(self.min_version)
def testRaisesWhenNoVersion(self): self.subprocess_mock.return_value = '' with self.assertRaisesRegex(git.InvalidGitException, ('The git version string is empty.')): git.CheckGitVersion(self.min_version)
def testRaisesWhenMinVersionIsSmaller(self): self.subprocess_mock.return_value = 'git version 1.8.9' with self.assertRaisesRegex( git.GitVersionException, (r'Your git version .*\..* is older than the minimum version (\d+)\.')): git.CheckGitVersion(self.min_version)
def testNoCheckMinVersion(self): self.subprocess_mock.return_value = 'git version 0.0.0' self.assertEqual(True, git.CheckGitVersion())
def testMatchesMinVersionWhenEqual(self): self.subprocess_mock.return_value = 'git version 2.0.1' self.assertEqual(True, git.CheckGitVersion(self.min_version))