def assertVersionLess(self, v1, v2): v1 = Version(v1) v2 = Version(v2) self.assertLess(v1, v2) self.assertGreater(v2, v1) self.assertNotEqual(v1, v2)
def test_version(self): with mock.patch('build_swift.shell.check_output') as check_output: check_output.return_value = 'xcrun version 42.\n' result = self.xcrun.version check_output.assert_called_with([self.xcrun.EXECUTABLE, '--version']) self.assertEqual(result, Version('42'))
def requires_python(version): """Decorator used to skip tests if the running Python version is not greater or equal to the required version. """ if isinstance(version, str): version = Version(version) if _PYTHON_VERSION >= version: return lambda func: func return unittest.skip( 'Requires Python version {} or greater'.format(version))
def test_sdk_build_version_known_sdk(self): with mock.patch('build_swift.shell.check_output') as check_output: check_output.return_value = '{}\n'.format(_KNOWN_SDK_BUILD_VERSION) result = self.xcrun.sdk_build_version(sdk=_KNOWN_SDK) command = [ self.xcrun.EXECUTABLE, '--sdk', _KNOWN_SDK, '--show-sdk-build-version', ] check_output.assert_called_with(command, stderr=shell.DEVNULL) self.assertEqual(result, Version(_KNOWN_SDK_BUILD_VERSION))
from build_swift.versions import Version __all__ = [ 'quiet_output', 'redirect_stderr', 'redirect_stdout', 'requires_attr', 'requires_module', 'requires_platform', 'requires_python', ] # ----------------------------------------------------------------------------- # Constants _PYTHON_VERSION = Version(platform.python_version()) # ----------------------------------------------------------------------------- # Helpers def _can_import(fullname): try: __import__(fullname) return True except ImportError: return False # -----------------------------------------------------------------------------
def test_str(self): for string in self.VERSION_COMPONENTS.keys(): version = Version(string) self.assertEqual(str(version), string)
def test_parse(self): for string, components in self.VERSION_COMPONENTS.items(): # Version parses version = Version(string) self.assertEqual(version.components, components)
def assertVersionNotEqual(self, v1, v2): v1 = Version(v1) v2 = Version(v2) self.assertNotEqual(v1, v2) self.assertNotEqual(v2, v1)
def test_str(self): for string in six.iterkeys(self.VERSION_COMPONENTS): version = Version(string) self.assertEqual(six.text_type(version), string)